mirror of
https://github.com/rsteube/carapace-bin.git
synced 2025-05-05 15:32:53 +00:00
carapace-bin
Multi-shell multi-command argument completer based on rsteube/carapace.
Supported shells:
- Bash
- Elvish
- Fish
- Oil broken (carapace#86)
- Powershell
- 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|oil|powershell|xonsh|zsh]
[ln|mkdir|chown...] <TAB>
Build
cd cmd/carapace && go generate ./... && go build -ldflags="-s -w"
For smallest file size (300kb instead of 6mb) use gccgo with flags "-s -w" and upx (upx slows down invocation but should still be fast enough).
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]
Generate completion
Ensure carapace is added to PATH.
- completion for carapace itself
carapace _carapace [bash|elvish|fish|oil|powershell|xonsh|zsh]
- 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.
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
cd carapace/cmd && ./generate.sh > completers.go
- build & test
docker-compose run --rm build
docker-compose run --rm [bash|elvish|fish|oil|powershell|xonsh|zsh]
Languages
Go
99.9%