fish-shell/share/functions/suspend.fish
Fabian Homborg 17c756971a Add a shell suspend function
Squashed commit of the following:

commit ede9e510751497d61ff0e78fd948e901171cf6f9
Merge: 938da30 239d2a2
Author: Fabian Homborg <FHomborg@gmail.com>
Date:   Thu Aug 6 18:47:43 2015 +0200

    Merge branch 'suspend' of https://github.com/mwm/fish-shell into suspend

commit 239d2a28e1
Author: Mike Meyer <mwm@mired.org>
Date:   Thu Aug 6 11:24:32 2015 -0500

    Handle interactive & login shells, SHLVL checks, and better message.

commit 6334047ebd
Author: Mike Meyer <mwm@mired.org>
Date:   Tue Aug 4 08:53:10 2015 -0500

    Add a description to suspend

commit 080458b31c
Author: Mike Meyer <mwm@mired.org>
Date:   Tue Aug 4 07:05:17 2015 -0500

    Add a shell suspend function
2015-08-30 18:42:35 +02:00

18 lines
543 B
Fish

# If the user hasn't set it, make sure our test level has a value
if not set -q suspend_minimum_SHLVL
set -g suspend_minimum_SHLVL 3
end
function suspend -d "Suspend the current shell."
if begin contains -- $argv --force
or not status --is-interactive
or begin test $SHLVL -ge $suspend_minimum_SHLVL
and not status --is-login
end
end
kill -STOP %self
else
echo 2>&1 Cannot suspend login shell or SHLVL to low, use --force to force.
end
end