Skip to content

feat: Add shell completions and shell completion command #1481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hschne
Copy link

@hschne hschne commented Apr 7, 2025

This PR adds shell completion functions for ZSH and Bash for Kamal. These are originally hosted in the kamal-complete repository, but I thought getting them in Kamal main made sense.

Apart from adding the completions this PR adds a command to print the completions. This is akin to what GitHub CLI and other tools do.

Testing

You can try those completions by adding them to your respective shell. Depends on your local setup. This is roughly what you'd usually do:

### bash

First, ensure that you install `bash-completion` using your package manager.

After, add this to your `~/.bash_profile`:

	eval "$(kamal completion -s bash)"

### zsh

Generate a `_kamal` completion script and put it somewhere in your `$fpath`:

	kamal completion -s zsh > /usr/local/share/zsh/site-functions/_kamal

Ensure that the following is present in your `~/.zshrc`:

	autoload -U compinit
	compinit -i

Considerations

  • I opted to put the completion files into the completions directory, which made it necessary to amend the gemspec. Happy to move it to a different directory if that makes more sense.
  • Happy to update the docs after this has been merged 👍
  • Would love to improve auto completion for aliases, but that would require a command to list aliases by name. Just a nice TODO for the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant