Skip to content

Instantly share code, notes, and snippets.

@dsamardzija
Last active December 18, 2015 20:29
Show Gist options
  • Save dsamardzija/5840456 to your computer and use it in GitHub Desktop.
Save dsamardzija/5840456 to your computer and use it in GitHub Desktop.
Shell prompt with git branch and dirty state
source ~/.git-completion.sh
COLOR_1="\[\e[0;32m\]" # green
COLOR_2="\[\e[1;34m\]" # blue
COLOR_3="\[\e[1;37m\]" # white
USER_AT_HOST="\u@\h"
TIME_WITH_BRACKETS="[\t]"
SPACE=" "
DIR="\w"
DIR_BASENAME="\W"
PROMPT="$"
GIT_PROMPT='$(__git_ps1 "[%s]")'
PS1=${COLOR_1}${TIME_WITH_BRACKETS}${SPACE}${USER_AT_HOST}${SPACE}${COLOR_3}${DIR_BASENAME}${SPACE}${GIT_PROMPT}${SPACE}${COLOR_1}${PROMPT}${SPACE}${COLOR_3}
@dsamardzija
Copy link
Author

looks something like this:
[02:32:55] dejan@magnus-01 cool_project [develop *] $

just add gist to your .bash_profile or .bashrc and copy .git-completion.sh file to appropriate location
you can find it at:
https://github.com/git/git/blob/master/contrib/completion/git-completion.bash

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