rndusr / stig

TUI and CLI for the BitTorrent client Transmission
GNU General Public License v3.0
547 stars 25 forks source link

zsh completions #203

Open rsekman opened 2 years ago

rsekman commented 2 years ago

The zsh shell offers powerful completion features for programs that supply completion specifications. E.g. git.

Given that stig can auto-generate its documentation, it should be possible to also auto-generate zsh completion files.

rndusr commented 2 years ago

That's one of those things on my list I'll probably never get to.

I'm not familiar with shell completion systems, but I was thinking about a two-stepped approach:

  1. Add a command that generates completion specs for a particular shell that contains all the commands and their static arguments.

  2. Add another command that dynamically generates completion candidates (e.g. torrent names) that can be used in step 1.

We can probably re-use the completion system that was added for the TUI. But this is the first time I dabbled with completion and I'm not very confident about it. It can be very slow in the TUI.

Using a stig subcommand in the shell completion also makes it very slow because the shell must spawn a new stig process for every completion. This issue could be solved by running stig in some kind of daemon mode.

rsekman commented 2 years ago

Tab completion for torrent names in the shell sounds overkill and like you say has performance issues. I was just thinking of generating at build time static completion files that the user or a package manager can install.

rndusr commented 2 years ago

Sure, better than nothing and much less work.

But I'm not sure completion files should be generated automatically. Users might not need or want them. Do we know for sure where to put them?

lmburns commented 2 years ago

I actually made my own zsh completions for this. They are as complete as I want them to be as of now. Took quite a while to do, but here they are in my dotfiles repo. By the way, this has torrent name completion and such. It works best with fzf-tab. rec