{"action":"created","issue":{"url":"https://api.github.com/repos/yadayada/acd_cli/issues/207","labels_url":"https://api.github.com/repos/yadayada/acd_cli/issues/207/labels{/name}","comments_url":"https://api.github.com/repos/yadayada/acd_cli/issues/207/comments","events_url":"https://api.github.com/repos/yadayada/acd_cli/issues/207/events","html_url":"https://github.com/yadayada/acd_cli/issues/207","id":119673057,"number":207,"title":"Zsh completion","user":{"login":"zmwangx","id":4149852,"avatar_url":"https://avatars.githubusercontent.com/u/4149852?v=3","gravatar_id":"","url":"https://api.github.com/users/zmwangx","html_url":"https://github.com/zmwangx","followers_url":"https://api.github.com/users/zmwangx/followers","following_url":"https://api.github.com/users/zmwangx/following{/other_user}","gists_url":"https://api.github.com/users/zmwangx/gists{/gist_id}","starred_url":"https://api.github.com/users/zmwangx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zmwangx/subscriptions","organizations_url":"https://api.github.com/users/zmwangx/orgs","repos_url":"https://api.github.com/users/zmwangx/repos","events_url":"https://api.github.com/users/zmwangx/events{/privacy}","received_events_url":"https://api.github.com/users/zmwangx/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yadayada/acd_cli/labels/CLI","name":"CLI","color":"000000"},{"url":"https://api.github.com/repos/yadayada/acd_cli/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-12-01T09:15:47Z","updated_at":"2015-12-03T21:26:40Z","closed_at":null,"body":"I just started using ACD and found this tool very helpful (thanks! I would have to write one myself otherwise since the Mac client is totally crap and web interface isn't very good either...). In an effort to learn the subcommands and their options, I wrote a complete Zsh completion definition that encompasses all subcommands, global and per-command options, as well as individual arguments.\r\n\r\n**The source file is here: https://github.com/zmwangx/zsh-completions/blob/master/src/_acd_cli.** In case something happens to the file or the repo in the future, here's a gist with the current definition (but it's unlikely that I'll update the gist): https://gist.github.com/ef40f29afad361b5a3fd. **To use it one needs to put it somewhere on the `$fpath` and load the new completion system with `compinit`** (which is probably already done for you if you have Prezto, OMZ etc. installed).\r\n\r\nNote that I've looked at the Bash completion in #127. I didn't want to maintain compatibility with Bash because I never bothered to learn the Bash completion system. Zsh does have `bashcompinit` that allegedly supports bash-styled completion definitions, but I've no idea how well it works. I'm not even sure if Bash's completion system is good enough to handle a fairly complex situation like this. Therefore, Zsh-only.\r\n\r\nI know my completion def is not perfect:\r\n\r\n* Most troublesome: completing remote paths. Not only is it slow (which I can't help — maybe it's just my heavily-loaded plattered disk, but it's more likely the API response time, which I haven't measured and likely never will need to, thanks to this project), but it has trouble completing weird paths (like ones with quotes in them), or when there are funny things in the argument to be completed, say a shell parameter. That's because the word I receive for completion is a verbatim copy of what's in the ZLE buffer, so I could get `word1\\ word2`, `'1'\\''2'`, `$HOME/bin`, etc. Currently my strategy is to strip all quoting (`'`, `\"`, `\\`), which should work reasonably well in the great majority of cases; and in the worst case you just don't get a match and have to type manually. I think it's okay though. After all I'm not in the position to write [`_path_files`](https://github.com/zsh-users/zsh/blob/master/Completion/Unix/Type/_path_files), and I can't. Maybe I don't need to (I'm not so familiar with zshcompsys), so any help is appreciated.\r\n\r\n    By the way, I looked at the Bash completion in #127 and the problem above seems to be ignored completely, whereas my simple strategy still covers most real world cases.\r\n\r\n* `acd_cli upload` has an unfortunate synopsis\r\n\r\n        acd_cli [options] upload [options] path [path ...] parent\r\n\r\n    One will immediately realize that it's impossible to know which argument is the parent (remote), since before you send the command with `accept-line`, any argument could potentially be the last one. I'm making a compromise here by assuming two positional arguments only, `path` and `parent`, because there are loads of ways to copy local paths. In case one wants to complete multiple local paths, the trick is to move the cursor to before the first path argument.\r\n\r\nSo the two problems stated above are the central ones. There might be other smaller issues that I've forgotten about. Anyway, the source file itself is fairly well-documented. Hope it helps some people.\r\n\r\nEdit: It goes without saying that comments, suggestions, bug reports and patches are welcome.\r\n"},"comment":{"url":"https://api.github.com/repos/yadayada/acd_cli/issues/comments/161789437","html_url":"https://github.com/yadayada/acd_cli/issues/207#issuecomment-161789437","issue_url":"https://api.github.com/repos/yadayada/acd_cli/issues/207","id":161789437,"user":{"login":"zmwangx","id":4149852,"avatar_url":"https://avatars.githubusercontent.com/u/4149852?v=3","gravatar_id":"","url":"https://api.github.com/users/zmwangx","html_url":"https://github.com/zmwangx","followers_url":"https://api.github.com/users/zmwangx/followers","following_url":"https://api.github.com/users/zmwangx/following{/other_user}","gists_url":"https://api.github.com/users/zmwangx/gists{/gist_id}","starred_url":"https://api.github.com/users/zmwangx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zmwangx/subscriptions","organizations_url":"https://api.github.com/users/zmwangx/orgs","repos_url":"https://api.github.com/users/zmwangx/repos","events_url":"https://api.github.com/users/zmwangx/events{/privacy}","received_events_url":"https://api.github.com/users/zmwangx/received_events","type":"User","site_admin":false},"created_at":"2015-12-03T21:26:39Z","updated_at":"2015-12-03T21:26:39Z","body":"@AlexCzar Also, how exactly are you installing the file? Please specify its full path, and show me your `$fpath`. I don't see a plugin called `zsh-completion` in OMZ, by the way.\r\n\r\nNote that the file has to be called `_acd_cli` (or at least something that begins with a `_`) to be inspected by `compinit`, so if you name it `blah.plugin.zsh` then it most definitely won't work."}}