Skip to content

Commit

Permalink
Update fish completions for new --list-languages format
Browse files Browse the repository at this point in the history
  • Loading branch information
eth-p authored and sharkdp committed May 14, 2019
1 parent 493a4e7 commit 06b8dcb
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions assets/completions/bat.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,14 @@

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

0 comments on commit 06b8dcb

Please sign in to comment.