Skip to content

Instantly share code, notes, and snippets.

@superjer
Last active December 14, 2015 09:50
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 superjer/5068108 to your computer and use it in GitHub Desktop.
Save superjer/5068108 to your computer and use it in GitHub Desktop.
Bash prompt with Git branch name & colors. It won't have much effect unless your system has the bash completion rules for Git installed. Add this to the end of your .bashrc file in your Home folder on whatever server you are working on. For it to take effect, you will have to log in again, or just run your .bashrc file.
GITBRANCH=''
if [ -f /etc/bash_completion.d/git ]; then
. /etc/bash_completion.d/git
GITBRANCH='$(__git_ps1)';
fi
# You can change the colors to what you want, especially if you have a 256 color terminal.
# Here's a color chart: http://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg
# Change the numbers in this column |
# |
# v
GOLDCOLOR='$(tput sgr0 && tput setaf 3)'
CYANCOLOR='$(tput sgr0 && tput setaf 6)'
RESETTTY='$(tput sgr0)'
PS1="\[$GOLDCOLOR\][\u@\h \W]\[$CYANCOLOR\]$GITBRANCH\[$GOLDCOLOR\]\$ \[$RESETTTY\]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment