dockit
dockit copied to clipboard
[Feature Request] Completion
It'd be nice to have completion of available images for dockit when installed, if the environment allows for it.
For example, with zsh
and oh-my-zsh
installed on ubuntu, placing this in ~/.zshrc
makes completion work nicely.
complete -C "docker images --format '{{.Repository}}:{{.Tag}}'" dockit
I like the idea. I'll have a look around myself, but do you know of any examples of installers that automatically modify shell startup scripts? I want to do it safely, though I know some refuse to do it at all (pyenv-installer will only print what you need to add, for example).
Instead of editing ~/.zshrc
or ~/.bashrc
, files can be placed for zsh / bash utilizing their autocompletion.
I believe for bash, the completions should be placed here, as that's where docker put theirs.
/usr/share/bash-completion/completions
This will list all the images (no auto complete with this implementation)
# Placed in /usr/share/bash-completion/completions/dockit
# dockit(1) completion -*- shell-script -*-
_dockit()
{
local images
images="$( docker images --format '{{.Repository}}:{{.Tag}}' )"
COMPREPLY=( $( compgen -W "$images" -- "$cur" ) )
__ltrim_colon_completions "$cur"
}
complete -F _dockit dockit
For zsh, placing this completion file and having oh-my-zsh seems to replicate the behavior. However, their ~/.zshrc
needs to have this line. This detail may be better served as a faq entry however as most users using zsh shouldn't have a problem.
autoload bashcompinit && bashcompinit
Placed in /usr/share/zsh/vendor-completions/_dockit
#compdef dockit
complete -C "docker images --format '{{.Repository}}:{{.Tag}}'" dockit
Sites for reference https://github.com/zsh-users/zsh-completions https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org