Show the time, the current folder where you are working and the current branch if working on a git repository. Output looks like 19:41:40 Documents@master$
. If using an xterm-256 terminal emulator, hour should be green, cwd white and the branch red.
function egit (){
function get_git_branch () {
command git rev-parse --abbrev-ref HEAD 2> /dev/null
}
# git specific usage for branching
function branch_separator () {
if [[ -n $(get_git_branch) ]]
then
echo "@"
fi
}
export TMP_GIT_PS1=${PS1} # back up the default settings
export PS1='\[\e[1;32m\]\t\[\e[m\]:\W\[\e[01;38;5;195m\]$(branch_separator)\[\e[m\]\[\e[01;38;5;196m\]$(get_git_branch)\[\e[m\]$ '
}
function dgit (){
export PS1=${TMP_GIT_PS1}
}
# enable git flavored prompt
egit;
This is awesome - thank you!