fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

チセfix: `__fish_systemctl_services` mode handling5d37698ef

master
1.2 KiB36 linesraw
1# localization: skip(private)
2function __fish_systemctl_services
3    if not type -q systemctl
4        return
5    end
6
7    # We don't want to complete with ANSI color codes
8    set -lu SYSTEMD_COLORS
9
10    # use the user specified mode, also exclude user defined alias
11    set -l tokens (commandline -xp)
12    # for determining whether user is using `journalctl`
13    set -l command $tokens[1]
14    set -l mode
15    for t in $tokens[2..]
16        switch $t
17            case --system --user
18                set mode $t
19            case --global
20                # `journalctl` does not have `global` option
21                if test "$command" != journalctl
22                    set mode $t
23                end
24            case --
25                break
26        end
27    end
28
29    set -l common_args --full --no-legend --no-pager --plain --type=service
30    begin
31        # `list-unit-files` will also show disabled units
32        systemctl $mode list-unit-files $common_args
33        # `list-units`      will not show disabled units but will show instances (like wpa_supplicant@wlan0.service)
34        systemctl $mode list-units --state=loaded $common_args
35    end 2>/dev/null | string split -f 1 ' '
36end