Skip to content

Commit efb0a7a

Browse files
authored
Update the Fish completer to leverage nushell/nushell#14399 (#1649)
1 parent 9447074 commit efb0a7a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cookbook/external_completers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ This completer will use [the fish shell](https://fishshell.com/) to handle compl
2121
```nu
2222
let fish_completer = {|spans|
2323
fish --command $'complete "--do-complete=($spans | str join " ")"'
24-
| $"value(char tab)description(char newline)" + $in
25-
| from tsv --flexible --no-infer
24+
| from tsv --flexible --noheaders --no-infer
25+
| rename value description
2626
}
2727
```
2828

2929
A couple of things to note on this command:
3030

3131
- The fish completer will return lines of text, each one holding the `value` and `description` separated by a tab. The `description` can be missing, and in that case there won't be a tab after the `value`. If that happens, `from tsv` will fail, so we add the `--flexible` flag.
32-
- `$"value(char tab)description(char newline)" + $in` exists to fix another edge case. Even with the `--flexible` flag, if the first line of the input doesn't have a second column the parser will skip that column for **all** the input. This is fixed adding a header to the input before-hand.
32+
- The output of the fish completer does not contain a header (name of the columns), so we add `--noheaders` to prevent `from tsv` from treating the first row as headers and later give the columns their names using `rename`.
3333
- `--no-infer` is optional. `from tsv` will infer the data type of the result, so a numeric value like some git hashes will be inferred as a number. `--no-infer` will keep everything as a string. It doesn't make a difference in practice but it will print a more consistent output if the completer is ran on it's own.
3434

3535
### Zoxide completer

0 commit comments

Comments
 (0)