2015-08-06 16:49:02 +00:00
|
|
|
function suspend -d "Suspend the current shell."
|
2016-10-17 22:30:28 +00:00
|
|
|
if contains -- $argv --help; or contains -- $argv -h
|
|
|
|
__fish_print_help suspend
|
|
|
|
and return 0
|
|
|
|
end
|
2015-08-06 16:49:02 +00:00
|
|
|
if begin contains -- $argv --force
|
2016-07-01 08:53:43 +00:00
|
|
|
or not status --is-interactive and not status --is-login
|
|
|
|
end
|
2016-07-01 09:20:32 +00:00
|
|
|
printf "Suspending %d: %sfg%s to resume" %self (set_color --bold) (set_color normal)
|
2016-07-01 08:53:43 +00:00
|
|
|
if contains -- $argv --force
|
2016-07-01 09:20:32 +00:00
|
|
|
printf " (or%s kill -CONT %d%s from another terminal)" (set_color --bold) %self (set_color normal)
|
2016-07-01 08:53:43 +00:00
|
|
|
end
|
2016-07-01 09:20:32 +00:00
|
|
|
# XXX not sure if this echo should be necessary, but without it, it seems
|
|
|
|
# everything printf'd above will not get pushed back to stdout before the suspend
|
|
|
|
echo ""
|
2016-07-01 09:48:50 +00:00
|
|
|
# XXX always causes a zombie until one fg's when we do this:
|
2016-07-01 08:53:43 +00:00
|
|
|
kill -STOP %self
|
2015-08-06 16:49:02 +00:00
|
|
|
else
|
2016-07-01 08:53:43 +00:00
|
|
|
echo 2>&1 "Refusing to suspend login shell."
|
|
|
|
echo 2>&1 "Use --force to override. This might hang your terminal."
|
2015-08-06 16:49:02 +00:00
|
|
|
end
|
|
|
|
end
|