mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-11-14 14:02:29 +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 completer = {|spans|
|
||||||
let fish_completer = {|spans|
|
|
||||||
fish --command $'complete "--do-complete=($spans | str join " ")"'
|
fish --command $'complete "--do-complete=($spans | str join " ")"'
|
||||||
| $"value(char tab)description(char newline)" + $in
|
| $"value(char tab)description(char newline)" + $in
|
||||||
| from tsv --flexible --no-infer
|
| 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 = {
|
$env.config = {
|
||||||
|
@ -15,9 +21,10 @@ $env.config = {
|
||||||
}
|
}
|
||||||
|
|
||||||
completions: {
|
completions: {
|
||||||
|
algorithm: "fuzzy"
|
||||||
external: (if (which fish | is-not-empty) { {
|
external: (if (which fish | is-not-empty) { {
|
||||||
enable: true
|
enable: true
|
||||||
completer: $fish_completer
|
completer: $completer
|
||||||
} } else { {} })
|
} } else { {} })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue