From b38ced856a4ffb3e159d855db701ae379b19dc76 Mon Sep 17 00:00:00 2001 From: "John P. Neumann" Date: Sun, 2 Apr 2017 14:09:58 -0500 Subject: [PATCH] Adds additional support for PS prompt context expansion --- modules/editor/README.md | 7 +++++++ modules/editor/init.zsh | 21 ++++++++++++++++++--- runcoms/zpreztorc | 3 +++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/modules/editor/README.md b/modules/editor/README.md index da0185f..44bc829 100644 --- a/modules/editor/README.md +++ b/modules/editor/README.md @@ -20,6 +20,13 @@ To enable the auto conversion of .... to ../.., add the following to zstyle ':prezto:module:editor' dot-expansion 'yes' +### PS Context + +To enable the prompt context to be set, add the following to your +*zpreztorc*. + + zstyle ':prezto:module:editor' ps-context 'yes' + Theming ------- diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh index 9aa64d6..e23fb0d 100644 --- a/modules/editor/init.zsh +++ b/modules/editor/init.zsh @@ -103,12 +103,27 @@ function editor-info { fi unset REPLY - - zle reset-prompt - zle -R + zle zle-reset-prompt } zle -N editor-info +# Reset the prompt based on the current context and +# the ps-context option. +function zle-reset-prompt { + if zstyle -t ':prezto:module:editor' ps-context; then + # If we aren't within one of the specified contexts, then we want to reset + # the prompt with the appropriate editor_info[keymap] if there is one. + if [[ $CONTEXT != (select|cont) ]]; then + zle reset-prompt + zle -R + fi + else + zle reset-prompt + zle -R + fi +} +zle -N zle-reset-prompt + # Updates editor information when the keymap changes. function zle-keymap-select { zle editor-info diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index e93ac6b..d1d97d2 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -51,6 +51,9 @@ zstyle ':prezto:module:editor' key-bindings 'emacs' # Auto convert .... to ../.. # zstyle ':prezto:module:editor' dot-expansion 'yes' +# Allow the zsh prompt context to be shown. +#zstyle ':prezto:module:editor' ps-context 'yes' + # # Git #