From 660505b4d8084a15b55213c85fba188999588657 Mon Sep 17 00:00:00 2001 From: Alexandros Kozak Date: Thu, 9 Sep 2021 13:24:11 -0700 Subject: [PATCH 1/4] Some global parameter declarations --- agkozak-zsh-prompt.plugin.zsh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/agkozak-zsh-prompt.plugin.zsh b/agkozak-zsh-prompt.plugin.zsh index 5e9ba6c..aa8f826 100644 --- a/agkozak-zsh-prompt.plugin.zsh +++ b/agkozak-zsh-prompt.plugin.zsh @@ -141,6 +141,30 @@ AGKOZAK[FUNCTIONS]='_agkozak_debug_print prompt_agkozak-zsh-prompt_preview prompt_agkozak-zsh-prompt_help' +# Some global declarations +typeset -g AGKOZAK_PROMPT_DEBUG \ + AGKOZAK_COLORS_EXIT_STATUS \ + AGKOZAK_COLORS_USER_HOST \ + AGKOZAK_COLORS_PATH \ + AGKOZAK_COLORS_BRANCH_STATUS \ + AGKOZAK_COLORS_PROMPT_CHAR \ + AGKOZAK_COLORS_CMD_EXEC_TIME \ + AGKOZAK_COLORS_VIRTUALENV \ + AGKOZAK_LEFT_PROMPT_ONLY \ + AGKOZAK_MULTILINE \ + AGKOZAK_NAMED_DIRS \ + AGKOZAK_PROMPT_DIRTRIM \ + AGKOZAK_PROMPT_DIRTRIM_STRING \ + AGKOZAK_SHOW_STASH \ + AGKOZAK_USER_HOST_DISPLAY \ + AGKOZAK_CMD_EXEC_TIME \ + AGKOZAK_BLANK_LINES \ + AGKOZAK_SHOW_VIRTUALENV + +typeset -ga AGKOZAK_CMD_EXEC_TIME_CHARS \ + AGKOZAK_VIRTUALENV_CHARS + +# Set AGKOZAK_PROMPT_DEBUG=1 for debugging mode : ${AGKOZAK_PROMPT_DEBUG:=0} ############################################################ @@ -162,12 +186,9 @@ _agkozak_debug_print() { if (( AGKOZAK_PROMPT_DEBUG )); then if is-at-least 5.4.0; then - for x in ${=AGKOZAK[FUNCTIONS]}; do - # Enable WARN_CREATE_GLOBAL for each function of the prompt - functions -W $x - done + # Enable WARN_CREATE_GLOBAL for each function of the prompt + functions -W ${=AGKOZAK[FUNCTIONS][@]} fi - unset x fi # Putting these default options here makes sure that the variables are in the @@ -982,6 +1003,7 @@ _agkozak_prompt_strings() { prompt_agkozak-zsh-prompt_setup() { # `emulate -L zsh' has been removed for promptinit # compatibility + typeset -g prompt_opts prompt_opts=( percent subst ) setopt NO_PROMPT_{BANG,CR,PERCENT,SUBST} "PROMPT_${^prompt_opts[@]}" From fdfb69070f17a3248c9a5fe7028202e7ae825721 Mon Sep 17 00:00:00 2001 From: Alexandros Kozak Date: Thu, 9 Sep 2021 14:36:08 -0700 Subject: [PATCH 2/4] Dead code --- agkozak-zsh-prompt.plugin.zsh | 1 - 1 file changed, 1 deletion(-) diff --git a/agkozak-zsh-prompt.plugin.zsh b/agkozak-zsh-prompt.plugin.zsh index aa8f826..f7c1318 100644 --- a/agkozak-zsh-prompt.plugin.zsh +++ b/agkozak-zsh-prompt.plugin.zsh @@ -137,7 +137,6 @@ AGKOZAK[FUNCTIONS]='_agkozak_debug_print prompt_agkozak_preexec prompt_agkozak_precmd _agkozak_prompt_strings - agkozak-zsh-prompt prompt_agkozak-zsh-prompt_preview prompt_agkozak-zsh-prompt_help' From b16bf4e1d09d94f63c4ed9756748ce64967e11c8 Mon Sep 17 00:00:00 2001 From: Alexandros Kozak Date: Thu, 9 Sep 2021 14:53:48 -0700 Subject: [PATCH 3/4] Support for promptinit's prompt_cleanup feature --- README.md | 3 +++ agkozak-zsh-prompt.plugin.zsh | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a4e4205..b4d06fd 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,9 @@ This prompt has been tested on numerous Linux and BSD distributions, as well as
Here are the latest features and updates. +- Unreleased + + Support for `promptinit`'s `prompt_cleanup` function + + Some global variable declarations - v3.10.0 + The prompt is now fully compatible with ZSH's `promptinit` function. - v3.9.0 diff --git a/agkozak-zsh-prompt.plugin.zsh b/agkozak-zsh-prompt.plugin.zsh index f7c1318..0562d79 100644 --- a/agkozak-zsh-prompt.plugin.zsh +++ b/agkozak-zsh-prompt.plugin.zsh @@ -138,7 +138,8 @@ AGKOZAK[FUNCTIONS]='_agkozak_debug_print prompt_agkozak_precmd _agkozak_prompt_strings prompt_agkozak-zsh-prompt_preview - prompt_agkozak-zsh-prompt_help' + prompt_agkozak-zsh-prompt_help + _agkozak_prompt_cleanup' # Some global declarations typeset -g AGKOZAK_PROMPT_DEBUG \ @@ -1057,6 +1058,10 @@ prompt_agkozak-zsh-prompt_setup() { (( $+VSCODE_PID )) && ZLE_RPROMPT_INDENT=6 fi + # For promptinit + (( ${+functions[prompt_cleanup]} )) && + prompt_cleanup _agkozak_prompt_cleanup + _agkozak_debug_print "Using async method: ${AGKOZAK[ASYNC_METHOD]}" } @@ -1113,4 +1118,20 @@ agkozak-zsh-prompt_plugin_unload() { unfunction $0 } +############################################################ +# promptinit cleanup function +############################################################ +_agkozak_prompt_cleanup() { + setopt LOCAL_OPTIONS NO_KSH_ARRAYS NO_SH_WORD_SPLIT + + add-zsh-hook -D preexec prompt_agkozak_preexec + add-zsh-hook -D precmd prompt_agkozak_precmd + + if is-at-least 5.3; then + add-zle-hook-widget -D zle-keymap-select _agkozak_zle-keymap-select + else + zle -D _agkozak_zle-keymap_select + fi +} + # vim: ts=2:et:sts=2:sw=2: From 73bcbd94c5b23fc2c9443dd8e33ecc3cc47f9523 Mon Sep 17 00:00:00 2001 From: Alexandros Kozak Date: Thu, 9 Sep 2021 17:07:14 -0700 Subject: [PATCH 4/4] Documentation --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b4d06fd..ab39c49 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,8 @@ This prompt has been tested on numerous Linux and BSD distributions, as well as
Here are the latest features and updates. -- Unreleased - + Support for `promptinit`'s `prompt_cleanup` function - + Some global variable declarations +- v3.10.1 + + The prompt now supports `promptinit`'s `prompt_cleanup` function. - v3.10.0 + The prompt is now fully compatible with ZSH's `promptinit` function. - v3.9.0