Skip to content

Instantly share code, notes, and snippets.

@rpearce
Last active July 26, 2016 08:39
Show Gist options
  • Save rpearce/82dc9f6b96d1a04dcff5 to your computer and use it in GitHub Desktop.
Save rpearce/82dc9f6b96d1a04dcff5 to your computer and use it in GitHub Desktop.
Bash prompt & git prompt setup
# ~/.bash_profile
export PATH=/Users/rpearce/bin:$PATH
export PATH="/usr/local/sbin:$PATH"
eval "$(rbenv init -)"
eval "$(hub alias -s)"
alias brewup="brew update && brew upgrade && brew cleanup"
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
DIR_COLOR="\[\e[0;32m\]"
GIT_BRANCH_COLOR="\[\e[0;36m\]"
GIT_CLEAN_COLOR="\[\e[1;32m\]"
GIT_DIRTY_COLOR="\[\e[0;31m\]"
PROMPT_COLOR="\[\033[38;5;172m\]"
RESET_COLOR="\[\e[0m\]"
PROMPT_CHARACTER="λ"
function __git_branch_status {
if $(__git_repo_initialized); then
if [[ -z $(git status -s) ]]; then
echo -e "$GIT_CLEAN_COLOR ✔"
else
echo -e "$GIT_DIRTY_COLOR ✗"
fi
fi
}
function __git_repo_initialized {
git ls-files >& /dev/null
}
function __git_branch_name {
if $(__git_repo_initialized); then
git symbolic-ref --short -q HEAD
fi
}
function __prompt_command {
PS1="\n$DIR_COLOR\w $GIT_BRANCH_COLOR$(__git_branch_name)$(__git_branch_status)$RESET_COLOR\n$PROMPT_COLOR$PROMPT_CHARACTER $RESET_COLOR"
}
PROMPT_COMMAND=__prompt_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment