Skip to content

Instantly share code, notes, and snippets.

@mfts
Last active December 12, 2018 10:24
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 mfts/0b3092738bc6a6b745a6 to your computer and use it in GitHub Desktop.
Save mfts/0b3092738bc6a6b745a6 to your computer and use it in GitHub Desktop.
Terminal prompt to show "user@computer:working_directory (git_branch) $ "
# Copy the functions below to your ~/.bash_profile
git-dirty() {
[[ $(git status 2>/dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*"
}
parse_git_branch() {
git branch 2> /dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/ (\1$(git-dirty))/"
}
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[0;34m\$(parse_git_branch)\[\033[00m\] $ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment