Skip to content

Instantly share code, notes, and snippets.

@melcloud
Created March 28, 2019 10:43
Show Gist options
  • Save melcloud/bd76783002d11ddffa168abe84508669 to your computer and use it in GitHub Desktop.
Save melcloud/bd76783002d11ddffa168abe84508669 to your computer and use it in GitHub Desktop.
Bash completion when running azure cli in docker
_python_argcomplete() {
local IFS=$'\013'
local SUPPRESS_SPACE=0
if compopt +o nospace 2> /dev/null; then
SUPPRESS_SPACE=1
fi
COMPREPLY=( $(docker run -i --rm -e "IFS=$IFS" \
-e "COMP_LINE=$COMP_LINE" \
-e "COMP_POINT=$COMP_POINT" \
-e "COMP_TYPE=$COMP_TYPE" \
-e "_ARGCOMPLETE_COMP_WORDBREAKS=$COMP_WORDBREAKS" \
-e "_ARGCOMPLETE=1" \
-e "_ARGCOMPLETE_SUPPRESS_SPACE=$SUPPRESS_SPACE" \
microsoft/azure-cli bash -c 'az 8>&1 9>&2 1>/dev/null 2>/dev/null') )
echo "COMREPLY $COMPREPLY"
if [[ $? != 0 ]]; then
unset COMPREPLY
elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "$COMPREPLY" =~ [=/:]$ ]]; then
compopt -o nospace
fi
}
complete -o nospace -F _python_argcomplete "az"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment