config.fish: lazy load job control functions

These don't really belong in config.fish.  Put them in function files,
like similar wrappers.  The redundancy is ugly but if it's a problem
we can use code generation to fix that.
This commit is contained in:
Johannes Altmanninger
2026-06-02 07:46:34 +08:00
parent f525b8a7b6
commit 616ff5c5e9
7 changed files with 30 additions and 21 deletions

View File

@@ -143,26 +143,6 @@ end
# PATH is possibly set above.
__fish_reconstruct_path
for jobbltn in bg wait disown
function $jobbltn -V jobbltn
set -l args (__fish_expand_pid_args $argv)
and builtin $jobbltn $args
end
end
function fg
set -l args (__fish_expand_pid_args $argv)
and builtin fg $args[-1]
end
if command -q kill
# Only define this if something to wrap exists
# this allows a nice "command not found" error to be triggered.
function kill
set -l args (__fish_expand_pid_args $argv)
and command kill $args
end
end
if status is-interactive
__fish_migrate
end

5
share/functions/bg.fish Normal file
View File

@@ -0,0 +1,5 @@
# localization: tier1
function bg
set -l args (__fish_expand_pid_args $argv)
and builtin bg $args
end

View File

@@ -0,0 +1,5 @@
# localization: tier1
function wait
set -l args (__fish_expand_pid_args $argv)
and builtin wait $args
end

5
share/functions/fg.fish Normal file
View File

@@ -0,0 +1,5 @@
# localization: tier1
function fg
set -l args (__fish_expand_pid_args $argv)
and builtin fg $args[-1]
end

View File

@@ -0,0 +1,9 @@
# localization: tier1
if command -q kill
# Only define this if something to wrap exists
# this allows a nice "command not found" error to be triggered.
function kill
set -l args (__fish_expand_pid_args $argv)
and command kill $args
end
end

View File

@@ -0,0 +1,5 @@
# localization: tier1
function wait
set -l args (__fish_expand_pid_args $argv)
and builtin wait $args
end

View File

@@ -5,7 +5,7 @@ fg (math 2 ^ 31 - 1)
fg (math 2 ^ 31)
# CHECKERR: fg: '2147483648' is not a valid process ID
# CHECKERR: {{.*}}config.fish (line {{\d+}}):
# CHECKERR: {{.*}}/fg.fish (line {{\d+}}):
# CHECKERR: and builtin fg $args[-1]
# CHECKERR: ^
# CHECKERR: in function 'fg' with arguments '2147483648'