Source

zshfiles / load / prompt.zsh

Full commit
### Prompt
typeset +x PS1     # Don't export PS1 - Other shells just mangle it.

#### Preexec is run after a command line is read, before the command is executed
# We use it to inform the prompt that error messages should once again be
# shown, and to set the screen name / titlebar text based on the command line,
# unless the user has disabled those features.
function preexec {
  booleancheck "$shellopts[preexec]" || return # Return if we're not wanted
  shownexterr=1
  #print -n "\e[K"    # Why did I do this?
}

#### Prompt setup functions
# Global color variable
PROMPT_COLOR_NUM=$(((${#${HOST#*.}}+11)%12))

autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
    colors
fi

for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
    eval PR_$color='$terminfo[bold]$fg[${(L)color}]'
    eval PR_LIGHT_$color='$fg[${(L)color}]'
    (( count = $count + 1 ))
done
PR_NO_COLOR="%{$terminfo[sgr0]%}"

function prompt-setup {
    ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[blue]%}["
    ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[blue]%}]%{$reset_color%}"
    ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
    ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
    ZSH_THEME_GIT_PROMPT_CLEAN=""

    PROMPT="%{$PR_YELLOW%}%n %{$PR_WHITE%}%~ %{$PR_NO_COLOR%}"
    RPROMPT='%{$PR_BLUE%}$(git_prompt_info)$(hg_prompt_info) %{$PR_YELLOW%}%D{%H:%M} %{$PR_BLUE%}%D{%d}%{$PR_NO_COLOR%}'
}

prompt-setup