Skip to content

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.

@airblade
Copy link
Contributor

As far as I can tell this hard-codes some accessory names instead of extracting the accessories from deploy.yml?

@hschne
Copy link
Author

hschne commented Aug 18, 2025

As far as I can tell this hard-codes some accessory names instead of extracting the accessories from deploy.yml?

That is correct. Ideally, Kamal would expose a command such as accessory list that could be used by completion functions, but I thought implementing such a thing without any completions in place. Hence hard-coded common accessories as first step.

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.

2 participants