Skip to content

Instantly share code, notes, and snippets.

@automagicaly
Last active December 6, 2019 18:48
Show Gist options
  • Save automagicaly/46c906cbb6024f1c8296fcce9c3db4b4 to your computer and use it in GitHub Desktop.
Save automagicaly/46c906cbb6024f1c8296fcce9c3db4b4 to your computer and use it in GitHub Desktop.
#############################################
# Functions
#############################################
get_git_branch(){
# Based on: http://stackoverflow.com/a/13003854/170413
local branch
if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then
if [[ "$branch" == "HEAD" ]]; then
branch='detached* '
fi
symbol=$'\ue725'
#git_branch="($symbol $branch) "
git_branch="($branch) "
else
git_branch=""
fi
}
#############################################
# Exports
#############################################
PROMPT_COMMAND="get_git_branch; $PROMPT_COMMAND"
export PS1="\W \[\e[33m\]\$git_branch\[\e[32m\]➤\[\e[0m\] "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment