mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-01 15:48:45 +00:00
1a93cbba1e
The echo command to print the last path segment got a couplel of fixes, but these fixes were only applied to the non-Darwin version. Copy these fixes over to the Darwin version. Notably, this makes `/` stop displaying as `//`.
22 lines
684 B
Fish
22 lines
684 B
Fish
|
|
if test (uname) = Darwin
|
|
function prompt_pwd --description "Print the current working directory, shortend to fit the prompt"
|
|
if test "$PWD" != "$HOME"
|
|
printf "%s" (echo $PWD|sed -e 's|^/private\(/.\{1,\}\)|\1|' -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g')
|
|
echo $PWD|sed -n -e 's-.*/\.\{0,1\}.\([^/]*\)-\1-p'
|
|
else
|
|
echo '~'
|
|
end
|
|
end
|
|
else
|
|
function prompt_pwd --description "Print the current working directory, shortend to fit the prompt"
|
|
switch "$PWD"
|
|
case "$HOME"
|
|
echo '~'
|
|
|
|
case '*'
|
|
printf "%s" (echo $PWD|sed -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g')
|
|
echo $PWD|sed -n -e 's-.*/\.\{0,1\}.\([^/]*\)-\1-p'
|
|
end
|
|
end
|
|
end
|