2
0
mirror of https://github.com/sharkdp/bat synced 2024-11-16 21:25:56 +00:00

Update fish completions for new --list-languages format

This commit is contained in:
Ethan P 2019-05-10 15:13:18 -07:00 committed by David Peter
parent 493a4e719e
commit 06b8dcb7eb

View File

@ -3,28 +3,14 @@
# Helper function: # Helper function:
function __bat_autocomplete_languages --description "A helper function used by "(status filename) function __bat_autocomplete_languages --description "A helper function used by "(status filename)
bat --list-languages | awk ' bat --list-languages | awk -F':' '
NR == 1 {
dc = 0;
while (substr($0, dc, 2) != " ") dc++;
while (substr($0, dc, 1) == " ") dc++;
}
{ {
langField = substr($0, 0, dc - 2); lang=$1
if (langField !~ /^ *$/) { split($2, exts, ",")
lang = langField;
sub(/ +$/, "", lang);
}
split(substr($0, dc), exts, ",");
for (i in exts) { for (i in exts) {
ext = exts[i] ext=exts[i]
if (ext !~ /[A-Z].*/ && ext !~ /^\..*rc$/) {
sub(/^ +/, "", ext); # Trim leading whitespace.
sub(/ +$/, "", ext); # Trim trailing whitespace.
if ((ext != "") && (ext !~ /[A-Z].*/)) {
print ext"\t"lang print ext"\t"lang
} }
} }