File: suspend.fish

package info (click to toggle)
fish 4.2.1-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 35,980 kB
  • sloc: python: 6,972; javascript: 1,407; sh: 1,009; xml: 411; ansic: 230; objc: 78; makefile: 20
file content (30 lines) | stat: -rw-r--r-- 837 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# localization: tier1

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
        __fish_print_help suspend
        return 0
    end

    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
    end

    if status is-interactive
        echo -ns 'Suspending ' $fish_pid ': run'
        echo -n (set_color --bold) 'kill -CONT' $fish_pid (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 $fish_pid
end