Frage

I track my billable hours. Every item has a description and a number of tags for different clients, projects etc.

Recently I added zsh completion for these tags. This is what I have in my zsh autocompletion file now:

_arguments "*:tags:( $(cat timetrackingdata | extract_tags.py ) )"

The python script extract_tags.py extracts all tags in my timetrackingdata file and gives them back to zsh.

I'd like to able to limit the tags returned by the tags already on the command line

So if I've already put the tag client1 on the command line I want to pass this tag to extract_tags.py so that it can filter it's output and only return tags that occur on items that also have the tag client1.

War es hilfreich?

Lösung

I think what you are looking for is the $words variable. This is an array of all words specified on the command line that magically exists inside completion functions.

Where is that documented? There are some passing references in man zshcompsys that I would have missed were I not specifically looking for them. However, I found it more clearly highlighted on this website.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top