Last active
April 7, 2024 05:00
-
-
Save davidmroth/fa26d433dd63ad799f7d384582e22ca4 to your computer and use it in GitHub Desktop.
Enabling `docker compose` alias, i.e., dc vs. docker compose
This file contains hidden or 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
# Add to your .bashrc | |
# https://www.gnu.org/software/gnuastro/manual/html_node/Bash-TAB-completion-tutorial.html | |
if which docker >/dev/null 2>&1; then | |
__docker_compose_cmdline_completion() { | |
local commands cur prev words cword | |
COMPREPLY=() | |
_get_comp_words_by_ref -n : cur prev words cword | |
#echo -e "\nCUR=$cur PREV=$prev WORDS=$words CWORD=$cword\n" | |
[[ "$prev" == "$words" ]] && prev='' | |
commands=$( echo $(eval "/usr/libexec/docker/cli-plugins/docker-compose __completeNoDesc $prev '$2'" 2>/dev/null) ) | |
commands=${commands%*:4} | |
IFS=$'\n' read -ra COMPREPLY -d '' < <(compgen -W "${commands[*]}" -- "$2") | |
return 0 | |
} | |
complete -F __docker_compose_cmdline_completion dc # If you change the alias, you'll have to change it here too (dc) | |
alias dc="docker compose" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment