#-------------------- # Terminal title #-------------------- # also found somewhere prompt_eof_setup() { # preexec() is run after you press enter on your command but before the command is run. preexec() { # define screen/terminal title with the current command (http://aperiodic.net/phil/prompt/) case $TERM in rxvt-unicode*) printf '\33]2;%s\007' $1 ;; screen*) local CMD=${1[(wr)^(*=*|sudo|ssh|exec|-*)]} printf '\ek%s\e\\' $CMD;; esac } } prompt_eof_setup "$@" EXITCODE="%(?..(%?%1) )" # function to show the current git branch in prompt parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } #-------------------- # Prompt #-------------------- # necessary if you want to use functions in the prompt # without this they wouldn't be run again precmd () { # this has to be on the edge or you have some spaces in the prompt # if you have any workaround please tell if [[ $UID != 0 ]]; then local username_color=$fg_blue else local username_color=$fg_red fi local host_color=$fg_light_green local path_color=$fg_light_blue local gitbranch_color=$fg_purple local exitcode_color=$fg_red PROMPT="${username_color}$USERNAME${fg_no_colour}@${host_color}%m${fg_no_colour}\ :${path_color}%~${fg_no_colour} ${gitbranch_color}$(parse_git_branch)${fg_no_colour} ${exitcode_color}$EXITCODE${fg_no_colour}> " } ## Spelling prompt SPROMPT='zsh: correct '%R' to '%r' ? ([Y]es/[N]o/[E]dit/[A]bort) ' # vim: set ft=zsh: