zsh-workers
 help / color / mirror / code / Atom feed
From: "Lawrence Velázquez" <larryv@zsh.org>
To: "Moritz Bunkus" <mo@bunkus.online>
Cc: zsh-workers@zsh.org
Subject: Re: Ansible tab completion: re-read cached hosts & groups on directory change
Date: Thu, 31 Mar 2022 01:55:49 -0400	[thread overview]
Message-ID: <cd169bfb-62ff-4a17-837a-28194677fea8@www.fastmail.com> (raw)
In-Reply-To: <877dbbopzo.fsf@bunkus.online>

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 <TAB>`, let tab completion cache hosts & groups
> 4. Hit <TAB> again to verify that the offered completions match expected
>    ones
> 5. cd into /path/to/other_ansible_tree
> 6. Type `ansible <TAB><TAB>` 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


  reply	other threads:[~2022-03-31  5:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07  9:21 Moritz Bunkus
2022-03-31  5:55 ` Lawrence Velázquez [this message]
2022-04-10 21:45   ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cd169bfb-62ff-4a17-837a-28194677fea8@www.fastmail.com \
    --to=larryv@zsh.org \
    --cc=mo@bunkus.online \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).