mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
update dirs
to use argparse
This commit is contained in:
parent
30baf8d101
commit
df65ed8696
1 changed files with 14 additions and 9 deletions
|
@ -1,15 +1,20 @@
|
||||||
function dirs --description 'Print directory stack'
|
function dirs --description 'Print directory stack'
|
||||||
# process options
|
set -l options 'h/help' 'c'
|
||||||
if set -q argv[1]
|
argparse -n dirs --max-args=0 $options -- $argv
|
||||||
switch $argv[1]
|
or return
|
||||||
case -c
|
|
||||||
# clear directory stack
|
if set -q _flag_help
|
||||||
|
__fish_print_help dirs
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
if set -q _flag_c
|
||||||
|
# Clear directory stack.
|
||||||
set -e -g dirstack
|
set -e -g dirstack
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# replace $HOME with ~
|
# Replace $HOME with ~.
|
||||||
string replace -r '^'"$HOME"'($|/)' '~$1' -- $PWD $dirstack | string join " "
|
string replace -r '^'"$HOME"'($|/)' '~$1' -- $PWD $dirstack | string join " "
|
||||||
echo
|
echo
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue