diff --git a/share/functions/prompt_pwd.fish b/share/functions/prompt_pwd.fish index eb7ef6190..8fe7f9815 100644 --- a/share/functions/prompt_pwd.fish +++ b/share/functions/prompt_pwd.fish @@ -39,6 +39,10 @@ function prompt_pwd --description 'Print the current working directory, shortene set -l all (string split -m (math $fish_prompt_pwd_full_dirs - 1) -r / $tmp) set tmp $all[1] set full $all[2..] + else if test $fish_prompt_pwd_full_dirs -eq 0 + # 0 means not even the last component is kept + string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*' '$1' $tmp + continue end string join / (string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp) $full diff --git a/tests/checks/prompt.fish b/tests/checks/prompt.fish index eb6d4825a..d2ddf492a 100644 --- a/tests/checks/prompt.fish +++ b/tests/checks/prompt.fish @@ -10,4 +10,4 @@ prompt_pwd -D 2 /usr/share/fish/tools/web_config/sample_prompts # CHECK: /u/s/f/t/web_config/sample_prompts prompt_pwd -D 0 /usr/share/fish/tools/web_config/sample_prompts -# CHECK: /u/s/f/t/w/sample_prompts +# CHECK: /u/s/f/t/w/s