Skip to content

Instantly share code, notes, and snippets.

@plainprogrammer
Last active December 10, 2015 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plainprogrammer/4385788 to your computer and use it in GitHub Desktop.
Save plainprogrammer/4385788 to your computer and use it in GitHub Desktop.
Custom BASH prompt including username, working directory, git branch and status on one line; followed by a simple prompt that reflects the exit status of the last command.
source /usr/local/etc/bash_completion.d/git-prompt.sh
function parse_git_dirty {
local retval=$?
[[ $(git status 2> /dev/null | tail -n1) != "" && $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
return $retval
}
function parse_git_branch {
local retval=$?
echo -e "$(__git_ps1)"
return $retval
}
export PS1="\n\u: \w [\[\033[1;35m\]\$(~/.rvm/bin/rvm-prompt i v g)\[\033[0m\]]\[\e[01;36m\]\$(parse_git_branch)\[\e[01;33m\]\$(parse_git_dirty)\n\`if [ \$? = 0 ]; then echo -e '\[\e[01;32m\]\xE2\x9C\x94'; else echo -e '\[\e[01;31m\]\xE2\x9C\x98'; fi\`\[\e[00m\] "
export PS2="\`echo -e '\xE2\x9E\x94'\` "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment