mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:39:52 +08:00
05daedf7c6
Adds behaviour similar to bash: - shorten dirs output by representing $HOME as ~; - provide a '-c' option to clear the stack
19 lines
527 B
Fish
19 lines
527 B
Fish
function dirs --description 'Print directory stack'
|
|
# process options
|
|
if count $argv >/dev/null
|
|
switch $argv[1]
|
|
case -c
|
|
# clear directory stack
|
|
set -e -g dirstack
|
|
return 0
|
|
end
|
|
end
|
|
|
|
# replace $HOME with ~
|
|
echo -n (echo (command pwd) | sed -e "s|^$HOME|~|")" "
|
|
for i in $dirstack
|
|
echo -n (echo $i | sed -e "s|^$HOME|~|")" "
|
|
end
|
|
echo
|
|
end
|