mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Add wrappers for fg/bg/wait to support job expansion
See commit 1c8bbfdb6d
for an alternative
approach, if this isn't desired.
This commit is contained in:
parent
1c8bbfdb6d
commit
9f3059b7f4
|
@ -256,3 +256,35 @@ end
|
|||
# Invoke this here to apply the current value of fish_user_path after
|
||||
# PATH is possibly set above.
|
||||
__fish_reconstruct_path
|
||||
|
||||
# Allow %n job expansion to be used with fg/bg/wait
|
||||
# `jobs` is the only one that natively supports job expansion
|
||||
function __fish_expand_pid_args
|
||||
for arg in $argv
|
||||
if string match -qr '^%\d+$' -- $arg
|
||||
# set newargv $newargv (jobs -p $arg)
|
||||
jobs -p $arg
|
||||
if not test $status -eq 0
|
||||
return 1
|
||||
end
|
||||
else
|
||||
echo $arg
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_expand_fg
|
||||
builtin fg (__fish_expand_pid_args $argv)
|
||||
end
|
||||
|
||||
function __fish_expand_bg
|
||||
builtin bg (__fish_expand_pid_args $argv)
|
||||
end
|
||||
|
||||
function __fish_expand_wait
|
||||
builtin wait (__fish_expand_pid_args $argv)
|
||||
end
|
||||
|
||||
alias fg __fish_expand_fg
|
||||
alias bg __fish_expand_bg
|
||||
alias wait __fish_expand_wait
|
||||
|
|
Loading…
Reference in New Issue
Block a user