Multi-shell multi-command argument completer based on rsteube/carapace.
Supported shells:
- Bash
- Elvish
- Fish
- Oil broken (carapace#86)
- Powershell
- Xonsh
- Zsh
A major part of the completers has been generated from help pages so there will be some quirks here and there. Also completion depends on what rsteube/carapace is capable of so far.
docker-compose run --rm build
docker-compose run --rm [bash|elvish|fish|oil|powershell|xonsh|zsh]
[ln|mkdir|chown...] <TAB>
Ensure carapace is added to PATH.
# bash (~/.bashrc)
source <(carapace _carapace)
# elvish (~/.elvish/rc.elv)
eval (carapace _carapace|slurp)
# fish (~/.config/fish/config.fish)
mkdir -p ~/.config/fish/completions
carapace --list | xargs -I{} touch ~/.config/fish/completions/{}.fish # disable auto-loaded completions (#185)
carapace _carapace | source
# oil (~/.config/oil/oshrc)
source <(carapace _carapace)
# powershell (~/.config/powershell/Microsoft.PowerShell_profile.ps1)
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
carapace _carapace | Out-String | Invoke-Expression
# xonsh (~/.config/xonsh/rc.xsh)
COMPLETIONS_CONFIRM=True
exec($(carapace _carapace xonsh))
# zsh (~/.zshrc)
source <(carapace _carapace zsh)
cd cmd/carapace && go generate ./... && go build -ldflags="-s -w"
Completers can also be built separately:
cd completers/ln_completer && go build -ldflags="-s -w"
./ln_completer _carapace [bash|elvish|fish|oil|powershell|xonsh|zsh]
Ensure carapace is added to PATH.
- completion for commands
carapace [ln|mkdir|...] [bash|elvish|fish|oil|powershell|xonsh|zsh]
- list completions
carapace --list
If the shell is left out carapace will try to determine it by the parent process name.
caraparse is a helper tool that uses regex to parse gnu help pages. Due to strong inconsistencies between these the results may differ but generally give a good head start.
- copy a completer for simplicity
cp -r completers/cp_completer completers/ln_completer
- update the package name in
main.go
- replace
root.go
ln --help | caraparse -n ln > completers/ln_completer/cmd/root.go
- fix issues and add completions as required
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"backup": carapace.ActionValues("existing", "nil", "none", "off", "numbered", "t", "simple", "never"),
"target-directory": carapace.ActionDirectories(),
})
carapace.Gen(rootCmd).PositionalAnyCompletion(
carapace.ActionFiles(""),
)
- run the generator
go generate ./...
- build & test
docker-compose run --rm build
docker-compose run --rm [bash|elvish|fish|oil|powershell|xonsh|zsh]