From 17a59bada7d66461584349169d8f65ee606b1a33 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Thu, 20 Jul 2017 19:08:19 -0500 Subject: [PATCH] [prompt] Rename helper function `promptpwd` to `prompt-pwd` for consistency Changes: * In prezto, function names are hyphenated ('-') by convention, rename `promptpwd` to `prompt-pwd` accordingly. * Unset local variable `current_pwd` proactively. * Tweak additional documentation for `prompt-pwd`. --- modules/prompt/README.md | 8 ++++++++ modules/prompt/functions/{promptpwd => prompt-pwd} | 12 +++++++++--- modules/prompt/functions/prompt_damoekri_setup | 2 +- modules/prompt/functions/prompt_paradox_setup | 2 +- modules/prompt/functions/prompt_sorin_setup | 2 +- runcoms/zpreztorc | 4 +++- 6 files changed, 23 insertions(+), 7 deletions(-) rename modules/prompt/functions/{promptpwd => prompt-pwd} (75%) diff --git a/modules/prompt/README.md b/modules/prompt/README.md index dd5349e..e106f2b 100644 --- a/modules/prompt/README.md +++ b/modules/prompt/README.md @@ -26,6 +26,14 @@ in *zpreztorc*. zstyle ':prezto:module:prompt' pwd-length 'short' ``` +### Prompt Display Length + +To change working directory prompt display length from 'short', set the +following to 'long' (without '~' expansion) or 'full' (with '~' expansion) +in *zpreztorc*. + + zstyle ':prezto:module:prompt' pwd-length 'short' + Theming ------- diff --git a/modules/prompt/functions/promptpwd b/modules/prompt/functions/prompt-pwd similarity index 75% rename from modules/prompt/functions/promptpwd rename to modules/prompt/functions/prompt-pwd index bf6e227..53613e7 100644 --- a/modules/prompt/functions/promptpwd +++ b/modules/prompt/functions/prompt-pwd @@ -1,7 +1,11 @@ -# prompt setup function common to many prompts -# moved to external function to reduce code redundancy +# +# Prompt setup function commonly used by prompt themes. +# +# Authors: +# Sorin Ionescu +# -# function promptpwd { +# function prompt-pwd { setopt localoptions extendedglob @@ -19,6 +23,8 @@ else ret_directory="${${${${(@j:/:M)${(@s:/:)current_pwd}##.#?}:h}%/}//\%/%%}/${${current_pwd:t}//\%/%%}" fi +unset current_pwd + print "$ret_directory" # } diff --git a/modules/prompt/functions/prompt_damoekri_setup b/modules/prompt/functions/prompt_damoekri_setup index 89e4d75..ca3b09e 100644 --- a/modules/prompt/functions/prompt_damoekri_setup +++ b/modules/prompt/functions/prompt_damoekri_setup @@ -16,7 +16,7 @@ prompt_damoekri_precmd() { unsetopt XTRACE KSH_ARRAYS # Format PWD. - _prompt_damoekri_pwd=$(promptpwd) + _prompt_damoekri_pwd=$(prompt-pwd) # Get Git repository information. if (( $+functions[git-info] )); then diff --git a/modules/prompt/functions/prompt_paradox_setup b/modules/prompt/functions/prompt_paradox_setup index c5a8751..088e77e 100644 --- a/modules/prompt/functions/prompt_paradox_setup +++ b/modules/prompt/functions/prompt_paradox_setup @@ -84,7 +84,7 @@ function prompt_paradox_precmd { unsetopt XTRACE KSH_ARRAYS # Format PWD. - _prompt_paradox_pwd=$(promptpwd) + _prompt_paradox_pwd=$(prompt-pwd) # Get Git repository information. if (( $+functions[git-info] )); then diff --git a/modules/prompt/functions/prompt_sorin_setup b/modules/prompt/functions/prompt_sorin_setup index 3a2a9f7..b37af7f 100644 --- a/modules/prompt/functions/prompt_sorin_setup +++ b/modules/prompt/functions/prompt_sorin_setup @@ -82,7 +82,7 @@ function prompt_sorin_precmd { unsetopt XTRACE KSH_ARRAYS # Format PWD. - _prompt_sorin_pwd=$(promptpwd) + _prompt_sorin_pwd=$(prompt-pwd) # Define prompts. RPROMPT='${editor_info[overwrite]}%(?:: %F{1}⏎%f)${VIM:+" %B%F{6}V%f%b"}' diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index 9fbc4f6..31368d1 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -97,7 +97,9 @@ zstyle ':prezto:module:editor' key-bindings 'emacs' # Auto set to 'off' on dumb terminals. zstyle ':prezto:module:prompt' theme 'sorin' -# Set how themes that use promptpwd function display the pwd, can be 'short', 'long', or 'full' +# Set the working directory prompt display length. +# By default, it is set to 'short'. Set it to 'long' (without '~' expansion) +# for longer or 'full' (with '~' expansion) for even longer prompt display. # zstyle ':prezto:module:prompt' pwd-length 'short' #