2018-01-18 22:15:49 +00:00
|
|
|
function suspend --description 'Suspend the current shell.'
|
|
|
|
set -l options 'h/help' 'f/force'
|
|
|
|
argparse -n suspend --max-args=1 $options -- $argv
|
|
|
|
or return
|
|
|
|
|
|
|
|
if set -q _flag_help
|
2016-11-28 05:27:22 +00:00
|
|
|
__fish_print_help suspend
|
2018-01-18 22:15:49 +00:00
|
|
|
return 0
|
2016-10-17 22:30:28 +00:00
|
|
|
end
|
2018-01-18 22:15:49 +00: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-06 16:49:02 +00:00
|
|
|
end
|
2018-01-18 22:15:49 +00:00
|
|
|
|
|
|
|
if status is-interactive
|
|
|
|
echo -ns 'Suspending ' %self ': run'
|
|
|
|
echo -n (set_color --bold) 'kill -CONT' %self (set_color normal)
|
|
|
|
echo 'from another terminal to resume'
|
|
|
|
end
|
|
|
|
|
|
|
|
# XXX always causes a zombie until one fg's when we do this:
|
|
|
|
kill -STOP %self
|
2015-08-06 16:49:02 +00:00
|
|
|
end
|