+# code in red and bold and the job count in yellow.
+PROMPT="$green%B%m%b$default:$blue%B%~%b$default \
+%(1j.$yellow%j$default.)%# \
+%(?..($red%B%?%b$default%) )"
+
+# VCS_Info was added in 4.3.9 but it works in earlier versions too. So load it
+# if the necessary files are available in ~/.zsh/functions/vcs_info (often a
+# symbolic link to current checkout of Zsh's sources).
+if [[ $ZSH_VERSION == (4.3.<9->|4.<4->*|<5->*) ||
+ -d ~/.zsh/functions/vcs_info ]]; then
+ # Update fpath to allow loading the VCS_Info functions.
+ if [[ -d ~/.zsh/functions/vcs_info ]]; then
+ fpath=(~/.zsh/functions/vcs_info/
+ ~/.zsh/functions/vcs_info/Backends
+ $fpath)
+ fi
+
+ # Allow substitutions and expansions in the prompt, necessary for
+ # VCS_info.
+ setopt promptsubst
+ # Load VCS_info to display information about version control repositories.
+ autoload -Uz vcs_info
+ # Only look for git and mercurial repositories; the only I use.
+ zstyle ':vcs_info:*' enable git hg
+ # Check the repository for changes so they can be used in %u/%c (see
+ # below). This comes with a speed penalty for bigger repositories.
+ zstyle ':vcs_info:*' check-for-changes true
+
+ # Set style of VCS_info display. The current branch (green) and VCS (blue)
+ # is displayed. If there is an special action going on (merge, rebase)
+ # it's also displayed (red).
+ zstyle ':vcs_info:*' formats \
+ "($green%b%u%c$default:$blue%s$default)"
+ zstyle ':vcs_info:*' actionformats \
+ "($green%b$default/$red%a$default:$blue%s$default)"
+ # Set style for formats/actionformats when unstaged (%u) and staged (%c)
+ # changes are detected in the repository; check-for-changes must be set to
+ # true for this to work. Thanks to Bart Trojanowski
+ # (http://jukie.net/~bart/blog/pimping-out-zsh-prompt) for the idea
+ # (2010-03-11 00:20).
+ zstyle ':vcs_info:*' unstagedstr '¹'
+ zstyle ':vcs_info:*' stagedstr '²'
+
+ # Call VCS_info as precmd before every prompt.
+ prompt_precmd() {
+ vcs_info
+ }
+ add-zsh-hook precmd prompt_precmd
+
+ # Display the VCS information in the right prompt.
+ if [[ $ZSH_VERSION == (4.3.<9->|4.<4->*|<5->*) ]]; then
+ RPROMPT='${vcs_info_msg_0_}'
+ # There is a bug in Zsh below 4.3.9 which displays a wrong symbol when
+ # ${vcs_info_msg_0_} is empty. Provide a workaround for those versions,
+ # thanks to Frank Terbeck <ft@bewatermyfriend.org> for it.
+ else
+ RPROMPT='${vcs_info_msg_0_:- }'
+ fi
+fi
+
+unset red blue green yellow default
+
+# When screen, xterm or rxvt is used set the name of the window to the
+# currently running program.
+#
+# When a program is started preexec() sets the window's name to it; when it
+# stops precmd() resets the window's name to 'zsh'.
+#
+# It works with screen, xterm and rxvt.
+#
+# If a command is run with sudo or if the shell is running as root then a ! is
+# added at the beginning of the command to make this clear. If a command is
+# running on a different computer with ssh a @ is added at the beginning. This
+# only works if the .zshrc on the server also uses this command.
+if [[ $TERM == screen* || $TERM == xterm* || $TERM == rxvt* ]]; then
+ # Is set to a non empty value to reset the window name in the next
+ # precmd() call.
+ window_reset=yes
+ # Is set to a non empty value when the shell is running as root.
+ if [[ $(id -u) -eq 0 ]]; then
+ window_root=yes
+ fi
+
+ window_preexec() {
+ # Get the program name with its arguments.
+ local program_name=$1
+
+ # When sudo is used use real program name instead, but with an
+ # exclamation mark at the beginning (handled below).
+ local program_sudo=
+ if [[ $program_name == sudo* ]]; then
+ program_name=${program_name#sudo }
+ program_sudo=yes
+ fi
+ # Remove all arguments from the program name.
+ program_name=${program_name%% *}
+
+ # Ignore often used commands which are only running for a very short
+ # time. This prevents a "blinking" name when it's changed to "cd" for
+ # example and then some milliseconds later back to "zsh".
+ [[ $program_name == (cd*|ls|la|ll|clear|c) ]] && return
+
+ # Change my shortcuts so the real name of the program is displayed.
+ case $program_name in
+ e)
+ program_name=elinks
+ ;;
+ g)
+ program_name=git
+ ;;
+ m)
+ program_name=mutt
+ ;;
+ v|vi)
+ program_name=vim
+ ;;
+ esac
+
+ # Add an exclamation mark at the beginning if running with sudo or if
+ # running zsh as root.
+ if [[ -n $program_sudo || -n $window_root ]]; then
+ program_name=!$program_name
+ fi
+
+ # Add an at mark at the beginning if running through ssh on a
+ # different computer.
+ if [[ -n $SSH_CONNECTION ]]; then
+ program_name="@$program_name"
+ fi
+
+ # Set the window name to the currently running program.
+ window_title "$program_name"
+
+ # Tell precmd() to reset the window name when the program stops.
+ window_reset=yes
+ }
+
+ window_precmd() {
+ # Abort if no window name reset is necessary.
+ [[ -z $window_reset ]] && return
+
+ # Reset the window name to 'zsh'.
+ local name="zsh"
+ # If the function was called with an argument then reset the window
+ # name to '.zsh' (used by clear alias).
+ if [[ -n $1 ]]; then
+ name=".zsh"
+ fi
+
+ # Prepend prefixes like in window_preexec().
+ if [[ -n $SSH_CONNECTION ]]; then
+ window_title "@$name"
+ elif [[ -n $window_root ]]; then
+ window_title "!$name"
+ else
+ window_title $name
+ fi
+
+ # Just reset the name, so no screen reset necessary for the moment.
+ window_reset=
+ }
+
+ # Sets the window title. Works with screen, xterm and rxvt.
+ window_title() {
+ if [[ $TERM == screen* ]]; then
+ print -n "\ek$1\e\\"
+
+ elif [[ $TERM == xterm* || $TERM == rxvt* ]]; then
+ print -n "\e]2;$1\e\\"
+ fi
+ }
+
+ # Add the preexec() and precmd() hooks.
+ add-zsh-hook preexec window_preexec
+ add-zsh-hook precmd window_precmd
+fi
+
+
+# COMPLETION SETTINGS
+
+# Load the complist module which provides additions to completion lists
+# (coloring, scrollable).
+zmodload zsh/complist
+# Use new completion system, store dumpfile in ~/.zsh/cache to prevent
+# cluttering of ~/. $fpath must be set before calling this. Thanks to Adlai in
+# #zsh on Freenode (2009-08-07 21:05) for reminding me of the $fpath problem.
+autoload -U compinit && compinit -d ~/.zsh/cache/zcompdump