Skip to content

Instantly share code, notes, and snippets.

@amoodie
Last active August 21, 2018 20:13
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 amoodie/4001f7f3c0be8aeb29828ecd7d9b7cfa to your computer and use it in GitHub Desktop.
Save amoodie/4001f7f3c0be8aeb29828ecd7d9b7cfa to your computer and use it in GitHub Desktop.
# added by AM
# Show git branch name
# based largely on code from ankurk91: https://gist.github.com/ankurk91/2efe14650d54d7d09528cea3ed432f6d#file-bashrc-md
# and
# Dominik Schoeler: https://makandracards.com/makandra/1090-customize-your-bash-prompt
#
force_color_prompt=yes
color_prompt=yes
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='\[\e[01;30m\]\t ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u \[\033[00m\]\[\033[01;34m\]\W:\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W$(parse_git_branch)\$ '
fi
unset color_prompt force_color_prompt
@ericbarefoot
Copy link

Yeah I like this. Definitely incorporating the git branch bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment