summaryrefslogtreecommitdiff
path: root/shell-completion/zsh/_systemd-run
blob: 4bfbd196ca6c9e7feb29eb93807e913457a81e24 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#compdef systemd-run

__systemctl() {
        local -a _modes
        _modes=("--user" "--system")
        systemctl ${words:*_modes} --full --no-legend --no-pager "$@" 2>/dev/null
}

__get_slices () {
        __systemctl list-units --all -t slice \
        | { while read -r a b; do echo $a; done; };
}

__slices () {
        local -a _slices
        _slices=(${(fo)"$(__get_slices)"})
        typeset -U _slices
        _describe 'slices' _slices
}

__get_machines () {
        machinectl --full --no-pager list | {while read -r a b; do echo $a; done;};
}

__machines () {
        local -a _machines
        _machines=("${(fo)$(__get_machines)}")
        typeset -U _machines
        if [[ -n "$_machines" ]]; then
                _describe 'machines' _machines
        else
                _message 'no machines'
        fi
}

_arguments \
        {-h,--help}'[Show help message]' \
        '--version[Show package version]' \
        '--user[Run as user unit]' \
        {-H+,--host=}'[Operate on remote host]:[user@]host:_sd_hosts_or_user_at_host' \
        {-M+,--machine=}'[Operate on local container]:machines:__machines' \
        '--scope[Run this as scope rather than service]' \
        '--unit=[Run under the specified unit name]:unit name' \
        '--description=[Description for unit]:description' \
        '--slice=[Run in the specified slice]:slices:__slices' \
        {-r,--remain-after-exit}'[Leave service around until explicitly stopped]' \
        '--send-sighup[Send SIGHUP when terminating]' \
        '*::command:_command'