From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9524 invoked from network); 10 Apr 2022 21:45:25 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Apr 2022 21:45:25 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1649627125; b=mkXaEwJ+zGRLMidSOY5f9jsQ1aw05XU17qj4aOhyrGMYrbGz+pr9QElN18cxkOeJ5VM4Z6qGsm 0tLBFH7faAoVFNDQzQi9oWDlgp1rwcY5tFAq8V6DiF2fmenuj1fEf6IOKdb4dqu3BaYBE9A4yO X+KNVqLYbPtbRlvfvAyLm0h31kLExZl457/ySjBke3Vjukv5ChUgtaIUU7hpeg2XjPCE7w5pdH jI4A5917tYxPZsKGupfX/BQ5IWxucpbWQu5lT1xs2nwWbLrZy/VbJEvPPykcT09VI/8AKg2SP2 wJSeCTHLBQ/nOyzW4qltE2m7vGstawU+gf5GcyRx6f5vng==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout5-smtp.messagingengine.com) smtp.remote-ip=64.147.123.21; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1649627125; bh=Pz2/njJwG1WYob9us4iA6Zl/hezsXsPwytX+H3+pRH0=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=QysZBUVGthZtjDU3xJH1bp1NZqZohaYn1khXfVFljHQkmcKOs4H3V/qSTn12m93AaMT0DbvhNH wzDTMuITFkI7vf9PZ9D+XimNLiE/WjlnAndcqIJ/mHo1Z9AcQKUR6iTg4pr3ORieS5tyUuu6JC PWmEsH/6mGT9oxVh6klUviDFv6b9dWZV/eF5yz9D6fxoKQa+2BkfPZAms85jzgjgpB5xjGlxqH kPVJ1JHeIH0RkSgGC9Cs8u7UhibenR5+x1gTJK2Lw59SOmOyqA/XMuTIAnGqJuOwu02hAtbmKz +opp+0ci5ir8GxwsF8VtO4vPt90/qGOdKnF3CWhXestapQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=1B/qmIquABpY0lncZFbpQ2G58ph8XM6xQ+tag8jYQUY=; b=SxKm1dY7KKbRH7Iukak5ILI4s4 bDV8vFWVUbwhbSPMN8TAVdEzQntxbW7eXWO8uEVOuyvmqKwXyXU9Qc3FCpBQKBn7ynMNZJLOSY7j8 EZzoFxA8hK9Nt4Ftos4/rL5FjiaC6r3R1nXu4Wrz6CHQsCIrm5FWfSORprXmLL/VZb+pV5/xhxHUf o5w6EGNVjLpfgBdeyrHUlJXUAv7bZKOLQfKRMq30yzTWAtUbDC6PNXC3xSVeYZNolDmZRVpWV69QX EMI/GI9tsGumd1gzCEyw8lO6+iVuOXKtHUO+RAgBegBmZpX89sRfaEGiaHfW0qcbXF4EYIGVyW6jJ vSzHn43A==; Received: from authenticated user by zero.zsh.org with local id 1ndfN7-0004GB-Br; Sun, 10 Apr 2022 21:45:25 +0000 Authentication-Results: zsh.org; iprev=pass (wout5-smtp.messagingengine.com) smtp.remote-ip=64.147.123.21; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:44757) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1ndfMt-0003wA-NB; Sun, 10 Apr 2022 21:45:12 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 15DAC3201EE4; Sun, 10 Apr 2022 17:45:10 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 10 Apr 2022 17:45:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; bh=1B/qmIquABpY0lncZFbpQ2G58ph8XM6xQ+tag8 jYQUY=; b=PFCciJwv/gvTzwPMKsNQxn/ciwEN4Q7PwIfQjnTI5JBh80TUIdoRbV Mpn6ipEeiGloKDNTb+gaqk1kdIb+Ltajj42biogrc8PQZ+tZUv8fp4xkOfprwRQq hmyKMY8qVqFK66egyorU2F7Js7Dm1RRH/IKInr4uc1P7oXzsor+kGUS8jWovsK8y rKur7kEvKKDUt7y368kURg7WAaQ6DRu7BnEJNdLWvnvx5AK60s++cmgKdX0v5U57 TPylFKEETCFZJozpRgLiatQXVrwsdss5IV/ZwiFRHxp24q9p6XiTE6iZPZYp87Kc p/rQ91haAnbCdjENj3CXUJnznI/R/UPA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=1B/qmIquABpY0lncZFbpQ2G58ph8XM6xQ+tag8jYQ UY=; b=iFyn3FARJtSLDtLEEd7tnfafC4lmN19dqDJ35C6yvM006fH6iz6tK3wGW 4eBsPHKVeP+bVnhaaOf4Gp4/Qo/AHu1W/MwsCHihYdccYeOTpB0dYki7fBv2Sg/h mLCSH2det1XGJdvLBT38hzWoFE10M7hTD/Zrxzzv0QsQD6gWLmTB8K3XzuxgdiX3 o7CaKmtLwJbrW3Y3e/AWIzkBEj0vijDcqxxKcCiuU4bU7o0ZCYZVMhY5WlOOCxVm DTpohV7YUpwEQX03p0wlLuJR8HSWqd9zWx53MF4RAO3n1XetGFdnujowrYloM4IQ PjSZQhmTorAuIaMj7oC8AClJUyvHg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudekgedgudeivdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtugfgjggfse htkedttddtreejnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggr nhhivghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpefgkefgfeejgf dvvdfguddtleelkedvfeetiedtudfhveevveduhfdvveeffedvueenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrsh hhrghhrghfrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 10 Apr 2022 17:45:09 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1000) id 4Kc5BC3L9wzT5; Sun, 10 Apr 2022 21:45:07 +0000 (UTC) Date: Sun, 10 Apr 2022 21:45:07 +0000 From: Daniel Shahaf To: Lawrence =?iso-8859-1?Q?Vel=E1zquez?= Cc: Moritz Bunkus , zsh-workers@zsh.org Subject: Re: Ansible tab completion: re-read cached hosts & groups on directory change Message-ID: <20220410214507.GE27526@tarpaulin.shahaf.local2> References: <877dbbopzo.fsf@bunkus.online> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 50033 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Lawrence Velázquez wrote on Thu, Mar 31, 2022 at 01:55:49 -0400: > Hi Moritz, > > On Fri, Jan 7, 2022, at 4:21 AM, Moritz Bunkus wrote: > > we have several Ansible repositories in different directories. I often have > > to switch between them. > > > > Unfortunately the tab completion for all the Ansible commands caches known > > Hosts & Groups in the global variables _ansible_hosts & > > _ansible_groups. For me the effect is that the wrong set of hosts & groups > > is offered when I change to a different Ansible repo. > > > > How to reproduce: > > > > 1. Have two or more Ansible repositories with different inventories > > somewhere > > 2. cd into /path/to/first_ansible_tree > > 3. Type `anssible `, let tab completion cache hosts & groups > > 4. Hit again to verify that the offered completions match expected > > ones > > 5. cd into /path/to/other_ansible_tree > > 6. Type `ansible ` and observe that the offered completions still > > come from the first_ansible_tree, not from other_ansible_tree > > > > As a quick workaround I've modified the completion to also cache the > > working directory where _ansible_hosts & _ansible_groups were created. If > > the current working directory doesn't match the cached working directory, > > both variables are unset & their values cached again. This seems to work. > > > > The attached patch implements this. Feel free to use it however you want, > > or to apply a totally different solution. > > Thanks for the contribution, and apologies for the delay. > > workers: Are we interested in integrating this? Yes. Tested, and it's correct, but we're in release freeze now ☹ An alternative would have been _store_cache with $PWD as part of the key (and possibly the hostname too, in case $HOME is shared across multiple hosts). Cheers, Daniel