Skip to content

Instantly share code, notes, and snippets.

@ambethia
Created December 1, 2009 06:57
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 ambethia/246121 to your computer and use it in GitHub Desktop.
Save ambethia/246121 to your computer and use it in GitHub Desktop.
# Bash prompt
parse_git_dirty() {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
parse_git_branch() {
git branch 2> /dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/[git: \1$(parse_git_dirty)]/"
}
export PS1="\n\033[1m\[\`if [[ \$? = "0" ]]; then echo '\e[32m\h\e[0m'; else echo '\e[31m\h\e[0m' ; fi\`\033[0m \w \$(parse_git_branch)\n∴ "
export PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME}:${PWD}\007"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment