mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 04:13:08 +00: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
1 changed files with 32 additions and 0 deletions
|
@ -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 a new issue