mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 21:18:53 +00:00
Improve dirs output and add -c option
Adds behaviour similar to bash: - shorten dirs output by representing $HOME as ~; - provide a '-c' option to clear the stack
This commit is contained in:
parent
f07d59c55d
commit
05daedf7c6
1 changed files with 17 additions and 8 deletions
|
@ -1,9 +1,18 @@
|
||||||
function dirs --description "Print directory stack"
|
function dirs --description 'Print directory stack'
|
||||||
echo -n (command pwd)" "
|
# process options
|
||||||
for i in $dirstack
|
if count $argv >/dev/null
|
||||||
echo -n $i" "
|
switch $argv[1]
|
||||||
end
|
case -c
|
||||||
echo
|
# 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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue