Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ The included installer script will install `dockit` to `/usr/local`. If that
doesn’t meet your needs, you can also run it directly from the cloned copy as
`bin/dockit`.

### Completion
Completion scripts are included for `bash` and `zsh`.
See `install.sh` for more information

## Usage

```text
Expand Down
37 changes: 34 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
#!/bin/bash
set -e

bash_complete_dir="/etc/bash_completion.d"
zsh_complete_dir="/usr/share/zsh/vendor-completions"

if [ ! $(id -u) -eq 0 ]
then
Expand All @@ -9,5 +13,32 @@ fi

dir=$(dirname "$0")

cp $dir/bin/dockit /usr/local/bin/dockit
cp -r $dir/lib/dockit /usr/local/lib
cp --update --verbose $dir/bin/dockit /usr/local/bin/dockit
cp --update --verbose --recursive $dir/lib/dockit /usr/local/lib

# Ensure that docker is installed and you are part of the docker group.
# This command will add you to the docker group:
# $usermod -a -G docker myusername"
if command -v bash &> /dev/null \
&& command -v docker &> /dev/null \
&& id -nG "$(whoami)" | grep -qw "docker"
then
mkdir -p "$bash_complete_dir"
cp --update --verbose misc/dockit.bashcompletion "$bash_complete_dir"/dockit
echo "bash completion script installed"
else
echo "bash completion script not installed"
fi

if command -v zsh &> /dev/null \
&& command -v docker &> /dev/null \
&& id -nG "$(whoami)" | grep -qw "docker"
then
mkdir -p "$zsh_complete_dir"
cp --update --verbose misc/dockit.zshcompletion "$zsh_complete_dir"/_dockit
echo "zsh completion script installed"
echo -e "\nYou may need to include this line in your ~/.zshrc file\n"
echo -e " autoload bashcompinit && bashcompinit\n"
else
echo "zsh completion script not installed"
fi
9 changes: 9 additions & 0 deletions misc/dockit.bashcompletion
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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
3 changes: 3 additions & 0 deletions misc/dockit.zshcompletion
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#compdef dockit

complete -C "docker images --format '{{.Repository}}:{{.Tag}}'" dockit