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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 19996 invoked from network); 31 Mar 2022 05:56:33 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 31 Mar 2022 05:56:33 -0000 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:Content-Type:Subject:Cc:To:From:Date: References:In-Reply-To:Message-Id:Mime-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=zTf0RHX2gxyZfjhaEZk29DB0KG85p2iizx9TDK47wxA=; b=nv+Y9rZguH9eNGS3o3URCjVX/S rFXabLRbYpJUhSSA8NunD188uZfOpA80NeP1dJpduGIJ5It07FApBZDrCsRDP23+uP1lJEL+tgB6G 151m1liah79SXS05sDUZNH/jWVax2b32eVGmX+Dk9FWY8LoWBdDa3u+kcvTwYAxw8d3I8DK53fOwr V8mvGFd+u4tc6JTKg7UgIrcpLWSRQPivz+08AOEHettTApnE0KMTA8+MwrBNuytsnICJyuRoAc6Kr 0+bF5cPbeB6ynpPgqnZVWvzwtoD3QwlkHVZTfPrGtKWkomQt/o1+YWiKQhVfe2TRGWpUyslkEHz9B VO1U0dsQ==; Received: from authenticated user by zero.zsh.org with local id 1nZnnN-0003Jc-FI; Thu, 31 Mar 2022 05:56:33 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nZnn1-0002yb-S8; Thu, 31 Mar 2022 05:56:12 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id 93D1527C005A; Thu, 31 Mar 2022 01:56:10 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute1.internal (MEProxy); Thu, 31 Mar 2022 01:56:10 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudeifedgleehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsehttd ertderreejnecuhfhrohhmpefnrgifrhgvnhgtvggpgggvlhojiihquhgviicuoehlrghr rhihvhesiihshhdrohhrgheqnecuggftrfgrthhtvghrnhepieekjeevledugeefiefgue elgffgtddtgeehvedvhedviefghedvffeuvddvueehnecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhihvodhmvghsmhhtphgruhhthh hpvghrshhonhgrlhhithihqdduudehudekjeejtdegqdduudelvdejfeekhedqlhgrrhhr hihvpeepiihshhdrohhrghesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3FF1E21E006E; Thu, 31 Mar 2022 01:56:10 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-382-g88b93171a9-fm-20220330.001-g88b93171 Mime-Version: 1.0 Message-Id: In-Reply-To: <877dbbopzo.fsf@bunkus.online> References: <877dbbopzo.fsf@bunkus.online> Date: Thu, 31 Mar 2022 01:55:49 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: "Moritz Bunkus" Cc: zsh-workers@zsh.org Subject: Re: Ansible tab completion: re-read cached hosts & groups on directory change Content-Type: text/plain X-Seq: 49935 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: 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? -- vq