From b3a2a7bfeb0fac4005435a0ca7027be55d077258 Mon Sep 17 00:00:00 2001 From: Zoey Llewellyn Hewll Date: Sun, 1 Oct 2017 12:02:36 +0800 Subject: [PATCH 1/2] Ensure 'full' pwd-length always expands '~' Prompt-pwd's 'full' option always expands '~', as opposed to only expanding when '~' would be followed by other directories. This means the path is always in a consistent format, rather than alternating between expanded and condensed. --- modules/prompt/functions/prompt-pwd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/prompt/functions/prompt-pwd b/modules/prompt/functions/prompt-pwd index 53613e72..ebab583a 100644 --- a/modules/prompt/functions/prompt-pwd +++ b/modules/prompt/functions/prompt-pwd @@ -12,11 +12,11 @@ setopt localoptions extendedglob local current_pwd="${PWD/#$HOME/~}" local ret_directory -if [[ "$current_pwd" == (#m)[/~] ]]; then +if zstyle -m ':prezto:module:prompt' pwd-length 'full'; then + ret_directory=${PWD} +elif [[ "$current_pwd" == (#m)[/~] ]]; then ret_directory="$MATCH" unset MATCH -elif zstyle -m ':prezto:module:prompt' pwd-length 'full'; then - ret_directory=${PWD} elif zstyle -m ':prezto:module:prompt' pwd-length 'long'; then ret_directory=${current_pwd} else From 2afa8e43ae44ccbd8e496e4aeb77b0113dd2d5af Mon Sep 17 00:00:00 2001 From: Zoey Llewellyn Hewll Date: Sun, 1 Oct 2017 12:03:45 +0800 Subject: [PATCH 2/2] Add pwd-length option 'tail' This option makes `prompt-pwd` only show the last directory in the path, for minimalist prompts --- modules/prompt/functions/prompt-pwd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/prompt/functions/prompt-pwd b/modules/prompt/functions/prompt-pwd index ebab583a..121fd942 100644 --- a/modules/prompt/functions/prompt-pwd +++ b/modules/prompt/functions/prompt-pwd @@ -19,6 +19,8 @@ elif [[ "$current_pwd" == (#m)[/~] ]]; then unset MATCH elif zstyle -m ':prezto:module:prompt' pwd-length 'long'; then ret_directory=${current_pwd} +elif zstyle -m ':prezto:module:prompt' pwd-length 'tail'; then + ret_directory=${current_pwd:t} else ret_directory="${${${${(@j:/:M)${(@s:/:)current_pwd}##.#?}:h}%/}//\%/%%}/${${current_pwd:t}//\%/%%}" fi