carapace-bin
Multi-shell multi-command argument completer based on rsteube/carapace.
Supported shells:
- Bash
- Elvish
- Fish
- Ion (experimental)
- Nushell (experimental)
- Oil
- Powershell
- Tcsh (experimental)
- Xonsh
- Zsh
Status
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.
Example
docker-compose run --rm build
docker-compose run --rm [bash|elvish|fish|ion|nushell|oil|powershell|tcsh|xonsh|zsh]
[ln|mkdir|chown...] <TAB>
Getting Started
Ensure carapace is added to PATH.
- completion for commands
# 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 | awk '{print $1}' | xargs -I{} touch ~/.config/fish/completions/{}.fish # disable auto-loaded completions (#185)
carapace _carapace | source
# nushell [needs fork: https://github.com/rsteube/nushell]
carapace _carapace nushell | save carapace.nu ; nu -c 'source carapace.nu'
# 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
# tcsh (~/.tcshrc)
set autolist
eval `carapace _carapace`
# xonsh (~/.config/xonsh/rc.xsh)
COMPLETIONS_CONFIRM=True
exec($(carapace _carapace))
# zsh (~/.zshrc)
source <(carapace _carapace)Replace _carapace with completer name to load a single one.
- list completions
carapace --listBuild
cd cmd/carapace && go generate ./... && go build -ldflags="-s -w" -tags releaseCompleters can also be built separately:
cd completers/ln_completer && go build -ldflags="-s -w"
./ln_completer _carapace [bash|elvish|fish|nushell|oil|powershell|tcsh|xonsh|zsh]Creating completers
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|ion|nushell|oil|powershell|tcsh|xonsh|zsh]