Skip to content

Instantly share code, notes, and snippets.

@raphaelhanneken
Last active December 1, 2017 16:07
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 raphaelhanneken/de460633280430246d4a7c002059f3a5 to your computer and use it in GitHub Desktop.
Save raphaelhanneken/de460633280430246d4a7c002059f3a5 to your computer and use it in GitHub Desktop.
A minimal bash theme
#!/usr/bin/env bash
txtblk='\[\e[0;30m\]' # Black
txtred='\[\e[0;31m\]' # Red
txtgrn='\[\e[0;32m\]' # Green
txtylw='\[\e[0;33m\]' # Yellow
txtblu='\[\e[0;34m\]' # Blue
txtpur='\[\e[0;35m\]' # Purple
txtcyn='\[\e[0;36m\]' # Cyan
txtwht='\[\e[0;37m\]' # White
bldblk='\[\e[1;30m\]' # Bold Black
bldred='\[\e[1;31m\]' # Bold Red
bldgrn='\[\e[1;32m\]' # Bold Green
bldylw='\[\e[1;33m\]' # Bold Yellow
bldblu='\[\e[1;34m\]' # Bold Blue
bldpur='\[\e[1;35m\]' # Bold Purple
bldcyn='\[\e[1;36m\]' # Bold Cyan
bldwht='\[\e[1;37m\]' # Bold White
txtrst='\[\e[0m\]' # Text Reset
PROMPT_COMMAND=__prompt_command
git_branch() {
if [[ -n $(git branch 2> /dev/null) ]]; then
echo "on ${bldcyn}$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')${txtrst}"
fi
}
__prompt_command() {
exit="$?"
if [ $exit != 0 ]; then
PS1="${bldred}\u"
else
PS1="${bldgrn}\u"
fi
PS1+="${txtrst} at ${bldblu}\h${txtrst} in ${bldpur}\W${txtrst} $(git_branch)\n${txtwht}» ${txtrst}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment