fork/fish-shell

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

Daniel Rainerformat: don't use tabs for indentatione0916e793

master
969 B30 linesraw
1# localization: skip(private)
2#
3# This function is used internally by the fish command completion code
4#
5
6# Perform this check once at startup rather than on each invocation
7if not type -q apropos
8    function __fish_describe_command
9    end
10    exit
11end
12
13function __fish_describe_command -d "Command used to find descriptions for commands"
14    argparse exact -- $argv
15    or return 1
16    set -l suffix
17    set -q _flag_exact && set suffix '$'
18
19    # $argv will be inserted directly into the awk regex, so it must be escaped
20    set -l argv_regex (string escape --style=regex -- "$argv")
21    __fish_apropos "^$argv$suffix" 2>/dev/null | awk -v FS=" +- +" '{
22        split($1, names, ", ");
23        for (name in names)
24            if (names[name] ~ /^'"$argv_regex"'.* *\([18]\)/ ) {
25                sub( "( |\t)*\\\([18]\\\)", "", names[name] );
26                sub( " \\\[.*\\\]", "", names[name] );
27                print names[name] "\t" $2;
28            }
29    }'
30end