mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
convert popd
and pushd
to use argparse
This commit is contained in:
parent
5ac8c42fad
commit
05aae4764b
2 changed files with 17 additions and 16 deletions
|
@ -1,11 +1,11 @@
|
|||
|
||||
function popd --description "Pop directory from the stack and cd to it"
|
||||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help popd
|
||||
return 0
|
||||
end
|
||||
set -l options 'h/help'
|
||||
argparse -n popd --max-args=0 $options -- $argv
|
||||
or return
|
||||
|
||||
if set -q _flag_help
|
||||
__fish_print_help popd
|
||||
return 0
|
||||
end
|
||||
|
||||
if set -q dirstack[1]
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
function pushd --description 'Push directory to stack'
|
||||
set -l options 'h/help'
|
||||
argparse -n pushd --max-args=1 $options -- $argv
|
||||
or return
|
||||
|
||||
if set -q _flag_help
|
||||
__fish_print_help pushd
|
||||
return 0
|
||||
end
|
||||
|
||||
set -l rot_r
|
||||
set -l rot_l
|
||||
|
||||
if count $argv >/dev/null
|
||||
# check for --help
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help pushd
|
||||
return 0
|
||||
end
|
||||
|
||||
if set -q argv[1]
|
||||
# emulate bash by checking if argument of form +n or -n
|
||||
if string match -qr '^-[0-9]+$' -- $argv[1]
|
||||
set rot_r (string sub -s 2 -- $argv[1])
|
||||
|
|
Loading…
Reference in a new issue