fork/fish-shell

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

Daniel Rainerl10n: implement `status language` builtinaa8f5fc77

master
7.8 KiB99 linesraw
1# Note that when a completion file is sourced a new block scope is created so `set -l` works.
2set -l __fish_status_all_commands \
3    basename \
4    build-info \
5    current-command \
6    current-commandline \
7    current-filename \
8    current-function \
9    current-line-number \
10    dirname \
11    features \
12    filename \
13    fish-path \
14    function \
15    get-file \
16    is-block \
17    is-breakpoint \
18    is-command-substitution \
19    is-full-job-control \
20    is-interactive \
21    is-interactive-job-control \
22    is-interactive-read \
23    is-login \
24    is-no-job-control \
25    job-control \
26    language \
27    line-number \
28    list-files \
29    print-stack-trace \
30    stack-trace \
31    terminal \
32    terminal-os \
33    test-feature \
34    test-terminal-feature
35
36# These are the recognized flags.
37complete -c status -s h -l help -d "Display help and exit"
38
39# The "is-something" subcommands.
40complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a is-login -d "Test if this is a login shell"
41complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a is-interactive -d "Test if this is an interactive shell"
42complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a is-interactive-read -d "Test if inside an interactive read builtin"
43complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a is-command-substitution -d "Test if a command substitution is currently evaluated"
44complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a is-block -d "Test if a code block is currently evaluated"
45complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a is-breakpoint -d "Test if a breakpoint is currently in effect"
46complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a is-no-job-control -d "Test if new jobs are never put under job control"
47complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a is-interactive-job-control -d "Test if only interactive new jobs are put under job control"
48complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a is-full-job-control -d "Test if all new jobs are put under job control"
49
50# The subcommands that are not "is-something" which don't change the fish state.
51complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a build-info -d "Print information on how this version fish was built"
52complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a current-command -d "Print the name of the currently running command or function"
53complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a current-commandline -d "Print the currently running command with its arguments"
54complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a current-filename -d "Print the filename of the currently running script"
55complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a filename -d "Print the filename of the currently running script"
56complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a basename -d "Print the file name (without the path) of the currently running script"
57complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a dirname -d "Print the path (without the file name) of the currently running script"
58complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a current-function -d "Print the name of the current function"
59complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a function -d "Print the name of the current function"
60complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a current-line-number -d "Print the line number of the currently running script"
61complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a line-number -d "Print the line number of the currently running script"
62complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a print-stack-trace -d "Print a list of all function calls leading up to running the current command"
63complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a stack-trace -d "Print a list of all function calls leading up to running the current command"
64complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a features -d "List all feature flags"
65complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a test-feature -d "Test if a feature flag is enabled"
66complete -f -c status -n "__fish_seen_subcommand_from test-feature" -a '(status features | sed "s/[[:space:]]\+[^[:space:]]*[[:space:]]\+[^[:space:]]*/\t/")'
67complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a fish-path -d "Print the path to the current instance of fish"
68complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a get-file -d "Print an embedded file from the fish binary"
69complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a list-files -d "List embedded files contained in the fish binary"
70complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a fish-path -d "Print the path to the current instance of fish"
71complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a terminal -d "Print name and version of the terminal fish is running in"
72complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a terminal-os -d "Print the operating system the terminal is running on"
73complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a test-terminal-feature -d "Test if the terminal suports the given feature"
74complete -f -c status -n "__fish_seen_subcommand_from test-terminal-feature" -a 'scroll-content-up\t"Command for scrolling up terminal contents"'
75
76# The job-control command changes fish state.
77complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a job-control -d "Set which jobs are under job control"
78complete -f -c status -n "__fish_seen_subcommand_from job-control" -a full -d "Set all jobs under job control"
79complete -f -c status -n "__fish_seen_subcommand_from job-control" -a interactive -d "Set only interactive jobs under job control"
80complete -f -c status -n "__fish_seen_subcommand_from job-control" -a none -d "Set no jobs under job control"
81
82complete -f -c status -n "__fish_seen_subcommand_from get-file" -a '(status list-files 2>/dev/null)'
83complete -f -c status -n "__fish_seen_subcommand_from list-files" -a '(status list-files 2>/dev/null)'
84
85# Tests equality between the command line with the first item removed
86# and the function's arguments.
87function __fish_status_is_exact_subcommand
88    set -l line (commandline -pxc)[2..]
89    test "$line" = "$argv"
90end
91# Tests if the command line with the first item removed starts with the provided arguments.
92function __fish_status_is_subcommand_prefix
93    set -l prefix (string escape --style=regex -- (string join -- ' ' $argv))
94    set -l line (string join -- ' ' (commandline -pxc)[2..])
95    string match -rq -- "^$prefix" $line
96end
97complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a language -d "Show or change fish's language settings"
98complete -f -c status -n "__fish_status_is_exact_subcommand language" -a "(echo list-available\tShow languages usable with \'status language set\'\nset\tSet the language\(s\) used for fish\'s messages\nunset\tUndo effects of \'status language set\'\n)"
99complete -f -c status -n "__fish_status_is_subcommand_prefix language set" -a "(status language list-available)"