# # A simple theme based off sorin # # Load dependencies. pmodload 'helper' # Show the hostname if this is an SSH session _prompt_my_host="" if [ ! -z "$SSH_CLIENT" ]; then _prompt_my_host=" %B%F{blue}| $(hostname | sed -e 's/\.local$//')%f%b" fi function _prompt_my_pwd { local pwd="${PWD/#$HOME/~}" if [[ "$pwd" == (#m)[/~] ]]; then __prompt_my_pwd="$MATCH" unset MATCH else __prompt_my_pwd="${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}/${pwd:t}" fi } # Only run git-info if a) the last command used git/hub or b) the pwd # has changed. function _prompt_git_preexec { [[ $2 =~ (git|hub) ]] && _EXEC_GIT_COMMAND=1 } function _prompt_git_precmd { if [ -n "$_EXEC_GIT_COMMAND" ]; then _prompt_git_chpwd unset _EXEC_GIT_COMMAND fi } function _prompt_git_chpwd { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS (( $+functions[git-info] )) && git-info } function prompt_my_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS prompt_opts=(cr percent subst) # Load required functions. autoload -Uz add-zsh-hook # Add hook for calling git-info before each command. add-zsh-hook precmd _prompt_git_precmd add-zsh-hook chpwd _prompt_git_chpwd add-zsh-hook preexec _prompt_git_preexec add-zsh-hook precmd _prompt_my_pwd # Set editor-info parameters. zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b' zstyle ':prezto:module:editor:info:keymap:primary' format '%B%F{red}$%f%b' zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format '%F{red}♺%f' zstyle ':prezto:module:editor:info:keymap:alternate' format '%B%F{green}#%f%b' # Set git-info parameters. zstyle ':prezto:module:git:info' verbose 'yes' zstyle ':prezto:module:git:info:branch' format ':%F{green}%b%f' zstyle ':prezto:module:git:info:dirty' format '%F{red}+%f' zstyle ':prezto:module:git:info:keys' format 'prompt' '' 'rprompt' '%b%D' # Define prompts. PROMPT=' ${editor_info[keymap]} ' RPROMPT='${editor_info[overwrite]}%F{cyan}${__prompt_my_pwd}${VIM:+" %B%F{green}V%f%b"}${_prompt_my_host}%(?:: %F{red}⏎%f)' # PROMPT='%f${git_info:+${(e)git_info[prompt]}}%(!. %B%F{red}#%f%b.)${editor_info[keymap]} ' # RPROMPT='${editor_info[overwrite]}${VIM:+" %B%F{green}V%f%b"}${git_info[rprompt]}${_prompt_my_host}%(?:: %F{red}⏎%f)' _prompt_git_chpwd } prompt_my_setup "$@"