prompt_pwd: Escape $HOME

This is used with a regex, so if it contained any metacharacters
they'd be used.
This commit is contained in:
Fabian Boehm 2022-09-04 09:18:57 +02:00
parent f9a5d4ec7f
commit 612e66af0f

View File

@ -26,7 +26,7 @@ function prompt_pwd --description 'short CWD for the prompt'
for path in $argv
# Replace $HOME with "~"
set -l realhome ~
set -l realhome (string escape --style=regex -- ~)
set -l tmp (string replace -r '^'"$realhome"'($|/)' '~$1' $path)
if test "$fish_prompt_pwd_dir_length" -eq 0