Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to generate multiple descriptions by allowing subshells #1660

Closed
rominf opened this issue Sep 2, 2014 · 2 comments
Closed
Labels

Comments

@rominf
Copy link
Contributor

rominf commented Sep 2, 2014

I propose to provide a way to generate dynamically multiple descriptions.

Why do I need it? I created completions for taskwarrior (console task management tool). It uses IDs to minimize typing. Of course you will not remember meanings of tens IDs, so I added completion that looks like this:

ID (task description)

In this case I have to add all completions for IDs separately, providing unique description for any ID. The problem is that when user adds new task, he don't see it in IDs completion, because it was generated once on a shell execution.

What I propose is 2 things:

  1. Allow call subshells for descriptions (like for arguments).
  2. Add argument to switch between modes "one description for everything" and "mapping descriptions to arguments". It could be -m --multiple-descriptions.

In my case adding completions for IDs would look like (task _zshids generates lines of a format ID:DESCRIPTION, _extract_id and _extract_description filter those lines, saving required part of line).

complete -c task --multiple-descriptions -a '(task _zshids | _extract_id)' -d '(task _zshids | _extract_description)'

In case argument count and description count not match, only first arguments that have mapped descriptions should be completed.

You can see the code here: https://git.tasktools.org/projects/TM/repos/task/browse/scripts/fish/task.fish?at=refs%2Fheads%2F2.4.0

I found a workaround, which almost works. I say "almost" due #380.

@danielmatz
Copy link
Contributor

You can already do this. Just have your task _zshids command print out an ID, a tab character, and then the description. And separate each ID and description pair with a newline of course.

In the documentation (http://fishshell.com/docs/current/index.html), the useful sections are "Writing your own completions" and "Useful functions for writing completions".

@rominf
Copy link
Contributor Author

rominf commented Sep 3, 2014

The description is separated from the completion by a tab character.

I missed this line in the documentation, sorry. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants