X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/blobdiff_plain/f6272d88eae76c8553f237f3f318c4a97997f262:/prompt_ben_setup..fa25023586cb94a1abf4fd3ff95ebe7c3c8ead09:/zsh/modules/prompt.zsh?ds=inline diff --git a/prompt_ben_setup b/zsh/modules/prompt.zsh similarity index 55% rename from prompt_ben_setup rename to zsh/modules/prompt.zsh index d164fd9..945d9eb 100644 --- a/prompt_ben_setup +++ b/zsh/modules/prompt.zsh @@ -1,7 +1,21 @@ -function prompt_ben_precmd { +autoload -Uz promptinit && promptinit + +if [[ "$TERM" == (dumb|linux|*bsd*) ]] || (( $#prompt_argv < 1 )); then + prompt 'off' +fi + +# +# Precmd +# + +function prompt_precmd { git-info } +# +# Functions +# + function virtualenv_info { if [[ -z "$VIRTUAL_ENV" ]]; then venv="default" @@ -33,16 +47,30 @@ function box_name { [ -f ~/.box-name ] && cat ~/.box-name || hostname -s } +# +# ZLE widgets +# + function zle-line-init zle-keymap-select { - local return_status="%{%F{red}%}%(?..✘)%{$reset_color%}" - RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}${return_status}%{$reset_color%}" + local return_status="%{%F{red}%}%(?..🆇)%{$reset_color%}" + if [ $KEYMAP = 'vicmd' ]; then + local edit_status="%{%F{cyan}%}🅽" + else + local edit_status="%{%F{green}%}🅸" + fi + + RPS1="${edit_status} ${return_status}%{$reset_color%}" RPS2=$RPS1 zle reset-prompt } zle -N zle-line-init zle -N zle-keymap-select -function prompt_ben_setup { +# +# Setup Prompt +# + +function prompt_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS prompt_opts=(cr percent subst) @@ -51,16 +79,16 @@ function prompt_ben_setup { autoload -Uz add-zsh-hook # Add hook for calling git-info before each command. - add-zsh-hook precmd prompt_ben_precmd + add-zsh-hook precmd prompt_precmd # Set git-info parameters. - zstyle ':prezto:module:git:info' verbose 'yes' - zstyle ':prezto:module:git:info:branch' format '@%F{cyan}%b%f' - zstyle ':prezto:module:git:info:clean' format '' - zstyle ':prezto:module:git:info:added' format '%{%F{green}%}!' - zstyle ':prezto:module:git:info:modified' format '%{%F{green}%}?' - zstyle ':prezto:module:git:info:untracked' format '%{%F{magenta}%}?' - zstyle ':prezto:module:git:info:keys' format \ + zstyle ':git:info' verbose 'no' + zstyle ':git:info:branch' format '@%F{cyan}%b%f' + zstyle ':git:info:clean' format '' + zstyle ':git:info:added' format '%{%F{green}%}!' + zstyle ':git:info:modified' format '%{%F{green}%}?' + zstyle ':git:info:untracked' format '%{%F{magenta}%}?' + zstyle ':git:info:keys' format \ 'prompt' '%b%a%m%u' # Define prompts. @@ -70,13 +98,5 @@ function prompt_ben_setup { %(?,,%{${%B%F{white}%}[%?]%{%f%b%} )$ ' } -prompt_ben_setup "$@" - -#setopt PROMPT_SUBST - -ZSH_THEME_GIT_PROMPT_PREFIX="@%{%F{cyan}%}" -ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DIRTY="%{%F{green}%}!" -ZSH_THEME_GIT_PROMPT_UNTRACKED="%{%F{green}%}?" -ZSH_THEME_GIT_PROMPT_CLEAN="" - +prompt_setup "$@" +setopt PROMPT_SUBST