Skip to content

Instantly share code, notes, and snippets.

@zanematthew
Last active August 20, 2016 19:30
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 zanematthew/934cc1e6c17aac0b453e to your computer and use it in GitHub Desktop.
Save zanematthew/934cc1e6c17aac0b453e to your computer and use it in GitHub Desktop.
The most awesome bash prompt e^er!1 // Place this code in your ~/.bash_prompt file
git_branch () { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'; }
HOST='\033[02;36m\]\h'; HOST=' '$HOST
TIME='\033[01;31m\]\t \033[01;32m\]'
LOCATION=' \033[01;34m\]`pwd | sed "s#\(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/\).*\(/[^/]\{1,\}/[^/]\{1,\}\)/\{0,1\}#\1_\2#g"`'
BRANCH=' \033[00;33m\]$(git_branch)\[\033[00m\]\n\$ '
PS1=$TIME$USER$HOST$LOCATION$BRANCH
PS2='\[\033[01;36m\]>'
@zanematthew
Copy link
Author

The above will display the following in the prompt:

<time (red)> <user (green)> <host (teal)> <full path (navy)> <git branch(yellow)>
$ (all commands are on a new line)

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