-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
Description
So I wanted to be able to use gitit to open any repo but hated having to cd somewhere or try to remember another person's username and full git repo name. I've started mocking up very simple tab completion for the gitit repo subcommand - initial work is here.
I'm new to zsh tab completion so the style is really bad and needs to be cleaned a lot before a possible PR.
Currently, it:
- completes ONLY the command
repo(I'll add the other commands soon?) - waits for you to type out a username, or completes usernames from a cache file
- once you complete a username, it checks the cache file - if it's too old or the user isn't there, it pulls from the GitHub API (and caches the results).
Usage:
$ gitit r<TAB>
$ gitit repo
$ gitit repo peterhurford <TAB> # note the space - this signifies a complete username
$ gitit repo peterhurford
64or32 loRem shellplyr
DMatrix.hs looker-lendingclub shinyview
...
# once a user's repos have been cached, you can then tab-complete that username
$ gitit repo pet<TAB>
$ gitit repo peterhurford
...This is completely up to you as the author, but I'm not sure if you feel this is scope or not? There are a few problems with the current form:
- (major) adds a shell dependency on the
jqtool (this line), which I use for parsing the JSON return. This could possibly be replaced withsedor the like since we're looking for a very specific field in the JSON. Of course, completion forrepocould just fail gracefully ifjqisn't installed, and other commands would complete fine. - (minor) is it depends on the public GitHub API, which is rate-limited at 60/hour, so if you go crazy trying to poll all your favorite authors from GitHub initially it'll start failing out (currently with incomprehensible messages)
- (minor) the API only returns at max 100 results at a time. The API includes a sort param for most recently updated, but if you're polling a user with more than 100 repos and looking for an old one, it currently won't show up in the results.
- (minor) adds a little bit of overhead to tab completion for the
repocommand
peterhurford