From 2a1a3cd45af8235a262dcf72a67b65f8de2b6d5c Mon Sep 17 00:00:00 2001 From: Colin Jamison Date: Sat, 21 Jan 2017 18:00:14 +0100 Subject: [PATCH] Implement keymode indicator --- modules/prompt/themes/eriner.zsh-theme | 10 +++++++++- modules/prompt/themes/gitster.zsh-theme | 8 ++++++++ modules/prompt/themes/magicmace.zsh-theme | 9 +++++++-- modules/prompt/themes/steeef.zsh-theme | 7 +++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/modules/prompt/themes/eriner.zsh-theme b/modules/prompt/themes/eriner.zsh-theme index 134a81c..b3a4d18 100644 --- a/modules/prompt/themes/eriner.zsh-theme +++ b/modules/prompt/themes/eriner.zsh-theme @@ -141,6 +141,12 @@ prompt_eriner_main() { prompt_eriner_precmd() { vcs_info PROMPT='%{%f%b%k%}$(prompt_eriner_main) ' + RPROMPT="${${KEYMAP/vicmd/[NORMAL]}/(main|viins)/}" +} + +zle-keymap-slect() { + prompt_eriner_precmd + zle reset-prompt } prompt_eriner_setup() { @@ -149,7 +155,9 @@ prompt_eriner_setup() { prompt_opts=(cr subst percent) - add-zsh-hook precmd prompt_eriner_precmd + add-zsh-hook prompt_eriner_precmd + + zle -N zle-keymap-select zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' check-for-changes false diff --git a/modules/prompt/themes/gitster.zsh-theme b/modules/prompt/themes/gitster.zsh-theme index e7eacb7..8b9a870 100644 --- a/modules/prompt/themes/gitster.zsh-theme +++ b/modules/prompt/themes/gitster.zsh-theme @@ -15,6 +15,12 @@ prompt_gitster_get_pwd() { prompt_gitster_precmd() { [[ ${+functions[git-info]} ]] && git-info + RPROMPT="${${KEYMAP/vicmd/[NORMAL]}/(main|viins)/}" +} + +zle-keymap-select() { + prompt_gitster_precmd + zle reset-prompt } prompt_gitster_setup() { @@ -24,6 +30,8 @@ prompt_gitster_setup() { prompt_opts=(cr percent subst) add-zsh-hook precmd prompt_gitster_precmd + + zle -N zle-keymap-select zstyle ':zim:git-info:branch' format '%b' zstyle ':zim:git-info:commit' format '%c' diff --git a/modules/prompt/themes/magicmace.zsh-theme b/modules/prompt/themes/magicmace.zsh-theme index bce1a87..ea495e7 100644 --- a/modules/prompt/themes/magicmace.zsh-theme +++ b/modules/prompt/themes/magicmace.zsh-theme @@ -44,6 +44,13 @@ prompt_magicmace_precmd() { if [[ ${+functions[git-info]} ]]; then git-info fi + PROMPT='${COLOR_USER_LEVEL}$(prompt_magicmace_status)[${COLOR_NORMAL}$(short_pwd)${COLOR_USER_LEVEL}]${(e)git_info[prompt]}── ─%f ' + RPROMPT="${${KEYMAP/vicmd/[NORMAL]}/(main|viins)/}" +} + +zle-keymap-select() { + prompt_magicmace_precmd + zle reset-prompt } prompt_magicmace_setup() { @@ -63,8 +70,6 @@ prompt_magicmace_setup() { 'prompt' '─[${COLOR_NORMAL}%b%c%D%A%B${COLOR_USER_LEVEL}]' # Call git directly, ignoring aliases under the same name. - PROMPT='${COLOR_USER_LEVEL}$(prompt_magicmace_status)[${COLOR_NORMAL}$(short_pwd)${COLOR_USER_LEVEL}]${(e)git_info[prompt]}── ─%f ' - RPROMPT='' } prompt_magicmace_setup "$@" diff --git a/modules/prompt/themes/steeef.zsh-theme b/modules/prompt/themes/steeef.zsh-theme index 0d44159..34400bb 100644 --- a/modules/prompt/themes/steeef.zsh-theme +++ b/modules/prompt/themes/steeef.zsh-theme @@ -40,11 +40,17 @@ prompt_steeef_precmd() { vcs_info 'prompt' fi + RPROMPT="${${KEYMAP/vicmd/[NORMAL]}/(main|viins)/}" PROMPT=' %{$purple%}%n${${reset_color}%} at %{$orange%}%m${${reset_color}%} in %{$limegreen%}%~${${reset_color}%} $vcs_info_msg_0_$(virtualenv_info)%{${reset_color}%} %(!.#.$) ' } +zle-keymap-select() { + prompt_steeef_precmd + zle reset-prompt +} + prompt_steeef_setup() { #use extended color pallete if available if [[ ${TERM} == *256* || ${TERM} == *rxvt* ]]; then @@ -96,6 +102,7 @@ prompt_steeef_setup() { add-zsh-hook preexec steeef_preexec add-zsh-hook chpwd steeef_chpwd add-zsh-hook precmd prompt_steeef_precmd + zle -N zle-keymap-select prompt_opts=(cr subst percent) }