Skip to content

Commit 670b230

Browse files
Handle some annoyances in fish external completer (#1955)
* Escape singlequotes in fish_completer In case the completion string has any singlequotes, escape them before passing it to external fish command. Else the completion will fail due to unmatched quotes. eg. vim '/home <tab> * fish_completer: expand path before returning completions This fixes completions for paths which have "~". ~ expansion will no longer work after the path is enclosed in double quotes, hence expand the path before returning the completion so that subsequent completions will continue to work eg. vim ~/Doc <tab> <tab> The second completion will not work as the path will be enclosed with double quotes after first completion
1 parent 62b143d commit 670b230

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cookbook/external_completers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ This completer will use [the fish shell](https://fishshell.com/) to handle compl
2020

2121
```nu
2222
let fish_completer = {|spans|
23-
fish --command $"complete '--do-complete=($spans | str join ' ')'"
23+
fish --command $"complete '--do-complete=($spans | str replace "'" "\\'" | str join ' ')'"
2424
| from tsv --flexible --noheaders --no-infer
2525
| rename value description
2626
| update value {
27-
if ($in | path exists) {$'"($in | str replace "\"" "\\\"" )"'} else {$in}
27+
if ($in | path exists) {$'"($in | path expand --no-symlink | str replace --all "\"" "\\\"" )"'} else {$in}
2828
}
2929
}
3030
```

0 commit comments

Comments
 (0)