mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-11-11 20:43:00 +01:00
nushell: escape external completions
This commit is contained in:
parent
b575bebe13
commit
1926aaf83e
1 changed files with 10 additions and 3 deletions
|
@ -1,8 +1,14 @@
|
|||
# See: https://www.nushell.sh/cookbook/external_completers.html#fish-completer
|
||||
let fish_completer = {|spans|
|
||||
let completer = {|spans|
|
||||
fish --command $'complete "--do-complete=($spans | str join " ")"'
|
||||
| $"value(char tab)description(char newline)" + $in
|
||||
| from tsv --flexible --no-infer
|
||||
| each { |comp|
|
||||
let escaped = $comp.value | str replace --all '"' '\"'
|
||||
{
|
||||
value: (if ($escaped | str contains " ") { $'"($escaped)"' } else { $escaped })
|
||||
description: $comp.description
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$env.config = {
|
||||
|
@ -15,9 +21,10 @@ $env.config = {
|
|||
}
|
||||
|
||||
completions: {
|
||||
algorithm: "fuzzy"
|
||||
external: (if (which fish | is-not-empty) { {
|
||||
enable: true
|
||||
completer: $fish_completer
|
||||
completer: $completer
|
||||
} } else { {} })
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue