RocHack / bb

Command line Blackboard client
MIT License
72 stars 8 forks source link

zsh completion #29

Open joeljk13 opened 9 years ago

joeljk13 commented 9 years ago

zsh is known for great completion; we should take advantage of that. I know at least @jeremywrnr and I use zsh.

jeremywrnr commented 9 years ago

Agreed! I have never made an autocompletion for a command line tool, but it would be awesome to have.

joeljk13 commented 9 years ago

I've created a zsh completion script! let me know if it gets things wrong or something - writing zsh completion has a really steep learning curve, so there's probably something wrong somewhere.

Just copy the _bb file to some directory in your $fpath. You can also add a directory to your fpath with fpath=(newdir $fpath).

jeremywrnr commented 9 years ago

Just tested, works great!!!

jeremywrnr commented 9 years ago

I don't even know how one would implement this, but it would be awesome would be to have dynamic secondary completions with the courses. For example, perhaps you could cache the course list after bb is logged in, so you could tab through the courses you are registered for after completing assignments, or grades, or any other command that can take in a course as an additional argument.

However, this would probably involve editing the existing bb code, so it may be more trouble than it is worth.

joeljk13 commented 9 years ago

yeah this would be cool. I probably would've implemented this if something had happened with #15. I don't think it would be difficult to implement, though - just save the courses to some file (like ~/.bbcourses or something) when ./bb courses is run, and have the completion script complete from that file (http://stackoverflow.com/questions/17318913/make-zsh-complete-arguments-from-a-file will help there).

jeremywrnr commented 9 years ago

Good point. I think it is worth opening a new issue 'dynamic secondary zsh completion', with this feature in mind. It may take a while for the dynamic completion to happen because of it's dependency on #15 . However, the standard zsh completion works well from my usage, so perhaps this original issue should be closed.

joeljk13 commented 9 years ago

Not sure whether it's worth opening a new issue. I probably won't bother but feel free to do so if you want.

Also note that this could be implemented for bash as well, once #15 is implemented.

jeremywrnr commented 9 years ago

Good point that this could be also implemented in bash. You are right, it is fairly minor - I won't open a new issue.