aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2015-09-28 20:43:30 +0300
committerBen Hilburn <bhilburn@gmail.com>2015-09-28 20:43:30 +0300
commitf18c92d76664f53351515f0f71a1047b7766648c (patch)
tree0057a1592087bc99b91175ea0a184a49c9d19d36 /powerlevel9k.zsh-theme
parent163a3738474cf7cc6b955ae757ff682ec1b06f88 (diff)
parentc760d3a5057698cd220caec1334403fc028f46f6 (diff)
Merge pull request #104 from dritter/vi_mode_cleanup
VI-mode cleanup
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rw-r--r--powerlevel9k.zsh-theme35
1 files changed, 25 insertions, 10 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index b85d9daa..6ea0cd64 100644
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -580,16 +580,6 @@ prompt_context() {
fi
}
-# Vi Mode: show editing mode (NORMAL|INSERT)
-prompt_vi_mode() {
- local mode="${${KEYMAP/vicmd/NORMAL}/(main|viins)/INSERT}"
- if [[ "$mode" == "NORMAL" ]]; then
- $1_prompt_segment "$0_NORMAL" "$DEFAULT_COLOR" "default" "$mode"
- else
- $1_prompt_segment "$0_INSERT" "$DEFAULT_COLOR" "blue" "$mode"
- fi
-}
-
# Dir: current working directory
prompt_dir() {
local current_path='%~'
@@ -817,6 +807,18 @@ prompt_time() {
"$1_prompt_segment" "$0" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$time_format"
}
+# Vi Mode: show editing mode (NORMAL|INSERT)
+prompt_vi_mode() {
+ case ${KEYMAP} in
+ main|viins)
+ "$1_prompt_segment" "$0_INSERT" "$DEFAULT_COLOR" "blue" "INSERT"
+ ;;
+ vicmd)
+ "$1_prompt_segment" "$0_NORMAL" "$DEFAULT_COLOR" "default" "NORMAL"
+ ;;
+ esac
+}
+
# Virtualenv: current working virtualenv
# More information on virtualenv (Python):
# https://virtualenv.pypa.io/en/latest/
@@ -876,6 +878,16 @@ $(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')"
fi
}
+function zle-line-init {
+ powerlevel9k_prepare_prompts
+ zle reset-prompt
+}
+
+function zle-keymap-select {
+ powerlevel9k_prepare_prompts
+ zle reset-prompt
+}
+
powerlevel9k_init() {
# Display a warning if the terminal does not support 256 colors
local term_colors
@@ -898,6 +910,9 @@ powerlevel9k_init() {
# prepare prompts
add-zsh-hook precmd powerlevel9k_prepare_prompts
+
+ zle -N zle-line-init
+ zle -N zle-keymap-select
}
powerlevel9k_init "$@"