Skip to content

Instantly share code, notes, and snippets.

@ajitkshirsagar
Last active June 15, 2022 15:14
Show Gist options
  • Save ajitkshirsagar/261a101f8c11749bc2c83c4a41e2aa80 to your computer and use it in GitHub Desktop.
Save ajitkshirsagar/261a101f8c11749bc2c83c4a41e2aa80 to your computer and use it in GitHub Desktop.
Git PS1

Download git-prompt.sh and save it to ~/.git-prompt.sh

curl https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh

Add following code to your ~/.bash_profile

   source ~/.git-prompt.sh

   # GIT PROMPT Variables
   GIT_PS1_DESCRIBE_STYLE='contains'
   GIT_PS1_SHOWCOLORHINTS='y'
   GIT_PS1_SHOWDIRTYSTATE='y'
   GIT_PS1_SHOWSTASHSTATE='y'
   GIT_PS1_SHOWUNTRACKEDFILES='y'
   GIT_PS1_SHOWUPSTREAM='auto'

   PS1='\[\e[1;32m\]\u\[\e[0;39m\]@\[\e[1;36m\]\h\[\e[0;39m\]:\D{%F %T}:\[\e[1;33m\]\w\[\e[0;39m\]\[\e[1;35m\]$(__git_ps1 " (%s)")\[\e[0;39m\] \[\e[1;37m\]$ '

Now you are all set!

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