When I type tmux a -t
and Tab
, zsh
shows a list of tmux sessions available for me. How does it work? If I have a user-defined command xxx
, how can I make zsh completion work? Do I have to obey certain standards?
Asked
Active
Viewed 636 times
0

youkaichao
- 1,938
- 1
- 14
- 26
-
See the chapter [Writing your own completion functions](https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org). – user1934428 Jan 07 '20 at 07:48
-
2Ultimately, there is a function `__tmux-sessions-separately` called which calls `tmux list-sessions` to see which sessions are active, and the output is used to populate the list of choices used by the completion function. You can look at `/usr/share/zsh/*/functions/_tmux` (or wherever your `zsh` package stores the functions) to see how it all works. – chepner Jan 08 '20 at 04:41