Last active
December 2, 2020 18:26
-
-
Save morganestes/58e7e6db63506e530e912ba7733c3fc6 to your computer and use it in GitHub Desktop.
Enable Docker.app completions in zsh, bash, or fish shells on macOS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Enable Docker.app completions in shells | |
# | |
# @param string $shell The shell to load completions for. Accepts "zsh", "bash", "fish". Default current shell. | |
function link_docker_completions() { | |
local shell="${1:-$(basename "$SHELL")}" | |
local etc="/Applications/Docker.app/Contents/Resources/etc" | |
local share_path="/usr/local/share/${shell}" | |
local completions_path | |
case $shell in | |
zsh) | |
completions_path="${share_path}/site-functions" | |
;; | |
bash) | |
completions_path="${share_path}-completion/completions" | |
;; | |
fish) | |
completions_path="${share_path}/vendor_completions.d" | |
;; | |
*) | |
echo -n "No completions available for ${shell}" | |
;; | |
esac | |
if [[ -n "${completions_path}" ]]; then | |
print "Linking completions for ${shell} into ${completions_path}\n" | |
find "${etc}" -type f -name "*.${shell}-completion" -exec ln -sf {} "${completions_path}/" \; | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment