diff --git a/argcomplete/shell_integration.py b/argcomplete/shell_integration.py index c41e194..e84f507 100644 --- a/argcomplete/shell_integration.py +++ b/argcomplete/shell_integration.py @@ -75,6 +75,10 @@ if [[ -z "${ZSH_VERSION-}" ]]; then complete %(complete_opts)s -F _python_argcomplete%(function_suffix)s %(executables)s else + # When called by the Zsh completion system, this will end with + # "loadautofunc" when initially autoloaded and "shfunc" later on, otherwise, + # the script was "eval"-ed so use "compdef" to register it with the + # completion system autoload is-at-least if [[ $zsh_eval_context == *func ]]; then _python_argcomplete%(function_suffix)s "$@"