fork/fish-shell

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

Johannes AltmanningerMerge branch 'completions-to-use-expanded-tokens'a9618477e

master
2.4 KiB37 linesraw
1# Completion for systemd's localectl
2set -l commands status set-locale list-locales set-keymap list-keymaps set-x11-keymap list-x11-keymap-{models,layouts,variants,options}
3
4complete -c localectl -f
5for cmd in $commands
6    complete -c localectl -n "not __fish_seen_subcommand_from $commands" -a $cmd
7end
8set -l localevars LANG LC_MESSAGES LC_{CTYPE,NUMERIC,TIME,COLLATE,MONETARY,MESSAGES,PAPER,NAME,ADDRESS,TELEPHONE,MEASUREMENT,IDENTIFICATION,ALL}
9set -l locales $localevars=(localectl list-locales 2>/dev/null)
10
11function __fish_localectl_layout
12    set -l cmd (commandline -pxc)
13    set -e cmd[1]
14    set -e cmd[1]
15    for l in (localectl list-x11-keymap-layouts)
16        if contains -- $l $cmd
17            echo $l
18            return 0
19        end
20    end
21    return 1
22end
23
24complete -c localectl -n "__fish_seen_subcommand_from set-locale" -a "$locales"
25complete -c localectl -n "__fish_seen_subcommand_from set-keymap" -a "(localectl list-keymaps)"
26# set-x11-keymap takes layout model variant option... (i.e. multiple options)
27complete -c localectl -n "__fish_seen_subcommand_from set-x11-keymap; and not __fish_seen_subcommand_from (localectl list-x11-keymap-layouts)" -a "(localectl list-x11-keymap-layouts)"
28complete -c localectl -n "__fish_seen_subcommand_from set-x11-keymap; and __fish_seen_subcommand_from (localectl list-x11-keymap-layouts); and not __fish_seen_subcommand_from (localectl list-x11-keymap-models)" -a "(localectl list-x11-keymap-models)"
29# Only complete variants for the current layout
30complete -c localectl -n "__fish_seen_subcommand_from set-x11-keymap; and __fish_seen_subcommand_from (localectl list-x11-keymap-models); and not __fish_seen_subcommand_from (localectl list-x11-keymap-variants)" -a "(localectl list-x11-keymap-variants (__fish_localectl_layout))"
31complete -c localectl -n "__fish_seen_subcommand_from set-x11-keymap; and __fish_seen_subcommand_from (localectl list-x11-keymap-variants)" -a "(localectl list-x11-keymap-options)"
32complete -c localectl -l no-ask-password -d "Don't ask for password"
33complete -c localectl -l no-convert -d "Don't convert keymap from console to X11 and vice-versa"
34complete -c localectl -s H -l host -d 'Execute the operation on a remote host'
35complete -c localectl -s h -l help -d 'Print a short help text and exit'
36complete -c localectl -l version -d 'Print a short version string and exit'
37complete -c localectl -l no-pager -d 'Do not pipe output into a pager'