mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 01:24:23 +08:00
prompt_pwd: full-dirs set to 0 means not even last component is safe
Alternative is to print an error.
This commit is contained in:
parent
af2952dd2f
commit
6c1ec98e92
|
@ -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 -l all (string split -m (math $fish_prompt_pwd_full_dirs - 1) -r / $tmp)
|
||||||
set tmp $all[1]
|
set tmp $all[1]
|
||||||
set full $all[2..]
|
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
|
end
|
||||||
|
|
||||||
string join / (string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp) $full
|
string join / (string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp) $full
|
||||||
|
|
|
@ -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
|
# CHECK: /u/s/f/t/web_config/sample_prompts
|
||||||
|
|
||||||
prompt_pwd -D 0 /usr/share/fish/tools/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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user