Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # set variables for git prompt
- set_current_git_branch(){
- CURRENT_GIT_BRANCH=`git branch 2>/dev/null | grep '* ' | sed s/'* '//` ;
- GIT_BRANCH_TEXT=''
- GIT_BRANCH_COLOR=''
- if [[ $CURRENT_GIT_BRANCH ]]; then
- GIT_BRANCH_TEXT="(git:$CURRENT_GIT_BRANCH) "
- GIT_BRANCH_COLOR="\[\033[01;31m\]"
- fi
- }
- # generate and set prompt
- set_prompt(){
- # set a fancy prompt (non-color, unless we know we "want" color)
- case "$TERM" in xterm-color|screen)
- export PS1="${GIT_BRANCH_COLOR}${GIT_BRANCH_TEXT}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\
- $ "
- ;;
- *)
- export PS1="${GIT_BRANCH_TEXT}\u@\h:\w\$ "
- ;;
- esac
- }
- PROMPT_COMMAND="$PROMPT_COMMAND set_current_git_branch; set_prompt; "
- # If this is an xterm set the title to (git:branch) user@host:dir
- case "$TERM" in
- xterm*|rxvt*)
- PROMPT_COMMAND=$PROMPT_COMMAND' echo -ne "\033]0;${GIT_BRANCH_TEXT}${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"; '
- ;;
- *)
- ;;
- esac
Add Comment
Please, Sign In to add comment