fish: erase existing for tombstone (#2704)

see 5918bca1eb
This commit is contained in:
Ralf Steube 2025-02-15 16:03:39 +01:00 committed by GitHub
parent 3f5bed15b2
commit 2298c0a5aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 41 additions and 12 deletions

View File

@ -8,16 +8,30 @@ import (
func Fish(completers []string) string {
snippet := `%v%v
function _carapace_lazy
complete -c $argv[1] -e
carapace $argv[1] fish | source
complete --do-complete=(commandline -cp)
function _carapace_quote_suffix
if not commandline -cp | xargs echo 2>/dev/null >/dev/null
if commandline -cp | sed 's/$/"/'| xargs echo 2>/dev/null >/dev/null
echo '"'
else if commandline -cp | sed "s/\$/'/"| xargs echo 2>/dev/null >/dev/null
echo "'"
end
else
echo ""
end
end
function _carapace_callback
commandline -cp | sed "s/\$/"(_carapace_quote_suffix)"/" | sed "s/ \$/ ''/" | xargs carapace $argv[1] fish
end
%v
`
complete := make([]string, len(completers))
for index, completer := range completers {
complete[index] = fmt.Sprintf(`complete -c '%v' -f -a '(_carapace_lazy %v)'`, completer, completer)
complete := make([]string, 0, len(completers)*2)
for _, completer := range completers {
complete = append(complete,
fmt.Sprintf(`complete -e '%v'`, completer),
fmt.Sprintf(`complete -c '%v' -f -a '(_carapace_callback %v)'`, completer, completer),
)
}
return fmt.Sprintf(snippet, pathSnippet("fish"), envSnippet("fish"), strings.Join(complete, "\n"))
}

View File

@ -3,3 +3,13 @@
![](./v1.x/banner.png)
Under development.
## Fish
With [4.0b1](https://github.com/fish-shell/fish-shell/releases/tag/4.0b1) onwards the following workaround is not needed anymore:
```sh
mkdir -p ~/.config/fish/completions
carapace --list | awk '{print $1}' | xargs -I{} touch ~/.config/fish/completions/{}.fish # disable auto-loaded completions (#185)
```
see [fish-shell/fish#6716](https://github.com/fish-shell/fish-shell/issues/6716)

View File

@ -39,13 +39,18 @@ eval (carapace _carapace|slurp)
```sh
# ~/.config/fish/config.fish
set -Ux CARAPACE_BRIDGES 'zsh,fish,bash,inshellisense' # optional
mkdir -p ~/.config/fish/completions
carapace --list | awk '{print $1}' | xargs -I{} touch ~/.config/fish/completions/{}.fish # disable auto-loaded completions (#185)
carapace _carapace | source
```
![](./setup-fish.png)
> With [4.0b1](https://github.com/fish-shell/fish-shell/releases/tag/4.0b1) onwards the following workaround is not needed anymore:
> ```sh
> mkdir -p ~/.config/fish/completions
> carapace --list | awk '{print $1}' | xargs -I{} touch ~/.config/fish/completions/{}.fish # disable auto-loaded completions (#185)
> ```
> see [fish-shell/fish#6716](https://github.com/fish-shell/fish-shell/issues/6716)
## Nushell
```sh

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/carapace-sh/carapace-bin
go 1.23.1
require (
github.com/carapace-sh/carapace v1.7.0
github.com/carapace-sh/carapace v1.7.1
github.com/carapace-sh/carapace-bridge v1.2.3
github.com/carapace-sh/carapace-selfupdate v0.0.10
github.com/carapace-sh/carapace-shlex v1.0.1

4
go.sum
View File

@ -1,5 +1,5 @@
github.com/carapace-sh/carapace v1.7.0 h1:uJK6qvrXow6ZylbjGrU1pEyFCg0ZQ/L951GcIdl2C7U=
github.com/carapace-sh/carapace v1.7.0/go.mod h1:fHdo3nEFe1QnIXxeA/Z1O9dCI83sfCsKfxrogpHfgtM=
github.com/carapace-sh/carapace v1.7.1 h1:GjMjPNEMHhTstneZD2M3Ypjb+lW5YNEV1AfYmRhsG4c=
github.com/carapace-sh/carapace v1.7.1/go.mod h1:fHdo3nEFe1QnIXxeA/Z1O9dCI83sfCsKfxrogpHfgtM=
github.com/carapace-sh/carapace-bridge v1.2.3 h1:lalVNRCyUqdPAJbrqkmIDKNnZYsBlo83JBsdP9WFzKM=
github.com/carapace-sh/carapace-bridge v1.2.3/go.mod h1:rEOS3MgzTQrCssS8WunHxPz31jZYNudcA7w1W5HrJs0=
github.com/carapace-sh/carapace-pflag v1.0.0 h1:uJMhl+vwEM/Eb0UdxZUuv4jo4rUAyPijkRGP5gfCuCE=