Skip to content

Instantly share code, notes, and snippets.

@liopic
Created November 10, 2015 08:37
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 liopic/27ec9733250376ec6cbe to your computer and use it in GitHub Desktop.
Save liopic/27ec9733250376ec6cbe to your computer and use it in GitHub Desktop.
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/|\1|/'
}
function precmd() {
PROMPT="~$(parse_git_branch)%# "
}
function proml {
local BLUE="\[\033[0;34m\]"
local LIGHT_BLUE="\[\033[1;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local WHITE="\[\033[0;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
local GRAY="\[\033[01;30m\]"
local RESTORE="\[\033[00m\]"
if [ $UID -eq 0 ]; then
PS1="$LIGHT_RED\u${LIGHT_BLUE}@\h$GRAY:\w$GREEN\$(parse_git_branch)${RESTORE}\$ "
else
PS1="$LIGHT_GREEN\u${LIGHT_BLUE}@\h$GRAY:\w$GREEN\$(parse_git_branch)${RESTORE}\$ "
fi
}
proml
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment