From 423bbfcafce950819f3dd5c6bdf47e700254a8f8 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 4 Jun 2026 06:13:19 +0200 Subject: 49676: _ansible: re-read cached hosts & groups on directory change --- Completion/Unix/Command/_ansible | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Completion/Unix/Command') diff --git a/Completion/Unix/Command/_ansible b/Completion/Unix/Command/_ansible index 554e61c49..b66f21523 100644 --- a/Completion/Unix/Command/_ansible +++ b/Completion/Unix/Command/_ansible @@ -208,10 +208,15 @@ case $state in 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 if [[ $state = hosts ]]; then suf=( -qS: ) -- cgit v1.3.1