--- /usr/share/zsh/functions/Completion/Unix/_ansible 2020-02-16 18:55:21.000000000 +0100 +++ /home/mosu/.config/zsh/functions/_ansible 2022-01-07 09:43:00.841820539 +0100 @@ -204,10 +204,15 @@ else local -a inventory typeset -ga _ansible_hosts _ansible_groups + typeset -g _ansible_inventory_last_cwd + if [[ $PWD != $_ansible_inventory_last_cwd ]]; then + unset _ansible_hosts _ansible_groups + fi if (( !$#_ansible_hosts || !$#_ansible_groups )); then inventory=( ${(f)"$(_call_program groups ansible-inventory --graph)"} ) _ansible_hosts=( ${${(M)inventory%--[^:]#}#--} ) _ansible_groups=( ${${${(M)inventory%@*:}%:}#@} ) + _ansible_inventory_last_cwd=$PWD fi [[ $IPREFIX = *[:,] ]] && alts=( 'operators:operator:_values -S "" operator "![exclude hosts]" "&[intersection of hosts]" "~[regular expression pattern]"' )