-
Notifications
You must be signed in to change notification settings - Fork 60
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
zsh completion for tarsnap 1.0.37 #226
Conversation
archive names may optionally be completed by setting the `archivefile` variable at the top of the file
@@ -0,0 +1,163 @@ | |||
#compdef tarsnap | |||
|
|||
# zsh completion function for tarsnap 1.0.37 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some hint for zsh users as to how they'd use this file? i.e. should it be copied into /usr/share/zsh/completion/
, or /etc/zsh/
, or $HOME/.zsh/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,163 @@ | |||
#compdef tarsnap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this file be put into misc/zsh_completion/_tarsnap
? Or some other filename, but definitely within misc/
and beginning with zsh
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave that to you :)
_tarsnap
Outdated
|
||
# Set the following variable to the path of a file containing the output from "tarsnap --list-archives" | ||
# i.e. one archive name per line. If left blank then archive names will not be completed. | ||
local archivefile= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little nitpicky, but could this variable be renamed to something like archivelist_file
? (or something similar, if underscores aren't allowed in zsh)
My first impression was that this was supposed to be a list of archives; I had to read the comment twice before I understood that it was supposed to point to a text file which contains a list of archive names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Also add note about where to store _tarsnap
Hmm, if I enter zsh and type:
(trying to get
Does zsh autocompletion work very differently than bash's? I also tried
and couldn't get it to complete |
That's because I used the SYNOPSIS in the man page for tarsnap as a guide. The |
Hmm, I see what you mean; the SYNOPSIS might be a bit misleading. Far below, in the EXAMPLES section, it states
In addition, the Yes, I definitely think that the man page is misleading. I'll revise it and discuss with @cperciva. |
I did make |
I'm still concerned about not being able to put options in whatever order I want. Again, writing
comes up with |
It's because it needs to see a mode option first. I can easily change it so that the order doesn't matter, but personally I prefer it that way since it makes it easier for me to remember the modes and important options (there are a lot of options that I will probably never use). |
Actually, just realised that the first option needs to be a mode so that it knows what other options to offer (unless you don't mind all options being available for all modes). |
@gperciva Is there a reason this is still open? I don't know if this was included in other changes. |
There's kind-of a reason. I have a branch which parses the man page and automatically adds args to the bash completion file (which prompted the recent #403 and #404). I'm now working on extending that to cover the zsh completion file. (Although I think I'll just have it give a warning, rather than attempting to automatically edit the file, since the zsh one also includes short doc strings.) I do hope to resolve this within a couple of PRs. |
(Note from the committer.) These were extracted from the zsh completion file proposed by vapniks in: #226
(Note from the committer.) These were extracted from the zsh completion file proposed by vapniks in: #226
Hi @vapniks, We now have a zsh completion file for tarsnap, added in #518. It's generated automatically from our man-page, so it should always be up-to-date. I'm terribly sorry about the 5-year delay. This rarely made it to the top of my todo list, and I'm not very familiar with zsh so it took a while until I was happy with a solution. I used your descriptions of options in this PR and rewrote them into 086c670. Thank you for your contribution! And sorry again for the delay. |
archive names may optionally be completed by setting the
archivefile
variable at the top of the file