Skip to content
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

Support shell command completion for Bash and other supported shells for better UX #152

Open
iamazeem opened this issue Feb 29, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@iamazeem
Copy link
Collaborator

Here's how minikube supports this as part of its binary:

$ minikube help completion 
Outputs minikube shell completion for the given shell (bash, zsh or fish)

	This depends on the bash-completion binary.  Example installation instructions:
	OS X:
		$ brew install bash-completion
		$ source $(brew --prefix)/etc/bash_completion
		$ minikube completion bash > ~/.minikube-completion  # for bash users
		$ minikube completion zsh > ~/.minikube-completion  # for zsh users
		$ source ~/.minikube-completion
		$ minikube completion fish > ~/.config/fish/completions/minikube.fish # for fish users
	Ubuntu:
		$ apt-get install bash-completion
		$ source /etc/bash-completion
		$ source <(minikube completion bash) # for bash users
		$ source <(minikube completion zsh) # for zsh users
		$ minikube completion fish > ~/.config/fish/completions/minikube.fish # for fish users

	Additionally, you may want to output the completion to a file and source in your .bashrc

	Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2
	Note for fish users: [2] please refer to this docs for more details https://fishshell.com/docs/current/#tab-completion

Usage:
  minikube completion SHELL [flags] [options]

Use "minikube options" for a list of global command-line options (applies to all commands).

zsv may also support shell command completion as part of its binary.

Here's a small PoC for Bash: https://github.com/iamazeem/zsv-bash-completion

Demo:

zsv-bash-completion-demo

@iamazeem iamazeem added the enhancement New feature or request label Feb 29, 2024
@liquidaty
Copy link
Owner

liquidaty commented Mar 15, 2024

Is this something that could easily be added as a makefile optional target that would install command completion when run?

@iamazeem
Copy link
Collaborator Author

Once we have consistent formatting for all the commands then this can simply be automated at runtime.
The completion script can provide the suggestions at runtime using the help text.
Currently, the help text differs from command to command as reported under #154.

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

No branches or pull requests

2 participants