2018-01-19 06:15:49 +08:00
|
|
|
function suspend --description 'Suspend the current shell.'
|
2020-03-10 02:36:12 +08:00
|
|
|
set -l options h/help f/force
|
2018-01-19 06:15:49 +08:00
|
|
|
argparse -n suspend --max-args=1 $options -- $argv
|
|
|
|
or return
|
|
|
|
|
|
|
|
if set -q _flag_help
|
2016-11-28 13:27:22 +08:00
|
|
|
__fish_print_help suspend
|
2018-01-19 06:15:49 +08:00
|
|
|
return 0
|
2016-10-18 06:30:28 +08:00
|
|
|
end
|
2018-01-19 06:15:49 +08:00
|
|
|
|
|
|
|
if not set -q _flag_force
|
|
|
|
and status is-login
|
|
|
|
and status is-interactive
|
|
|
|
|
|
|
|
echo 2>&1 'Refusing to suspend interactive login shell.'
|
|
|
|
echo 2>&1 'Use --force to override. This might hang your terminal.'
|
|
|
|
return 1
|
2015-08-07 00:49:02 +08:00
|
|
|
end
|
2018-01-19 06:15:49 +08:00
|
|
|
|
|
|
|
if status is-interactive
|
2018-03-16 07:31:15 +08:00
|
|
|
echo -ns 'Suspending ' $fish_pid ': run'
|
|
|
|
echo -n (set_color --bold) 'kill -CONT' $fish_pid (set_color normal)
|
2018-01-19 06:15:49 +08:00
|
|
|
echo 'from another terminal to resume'
|
|
|
|
end
|
|
|
|
|
|
|
|
# XXX always causes a zombie until one fg's when we do this:
|
2018-03-16 07:31:15 +08:00
|
|
|
kill -STOP $fish_pid
|
2015-08-07 00:49:02 +08:00
|
|
|
end
|