Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to add/update completion scripts from Docker for Mac. Assumes that bash-completion or bash-completion@2 in installed with Homebrew
#!/usr/bin/env bash
update-docker-completions() {
local prefix suffix srcdir='/Applications/Docker.app/Contents/Resources/etc'
# bash
prefix='/usr/local/etc/bash_completion.d/'
suffix=''
for compl in "$srcdir"/*.bash-completion; do
ln -sf "$compl" "${prefix}$(basename "${compl%.*-completion}")${suffix}"
done
# zsh
prefix='/usr/local/share/zsh/site-functions/_'
suffix=''
for compl in "$srcdir"/*.zsh-completion; do
ln -sf "$compl" "${prefix}$(basename "${compl%.*-completion}")${suffix}"
done
# fish
prefix='/usr/local/share/fish/vendor_completions.d/'
suffix='.fish'
for compl in "$srcdir"/*.fish-completion; do
ln -sf "$compl" "${prefix}$(basename "${compl%.*-completion}")${suffix}"
done
}
[[ "$0" == "$BASH_SOURCE" ]] && update-docker-completions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.