|
| 1 | +# zsh-manpage-completion-generator |
| 2 | + |
| 3 | +Automatically generate zsh completions from man page using fish shell completion files. |
| 4 | +This program is inspired from [nevesnunes/sh-manpage-completions](https://github.com/nevesnunes/sh-manpage-completions). |
| 5 | +But it supports more completion files and is much simply implemented, faster and easier to use, written in Go. |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +This program depends on fish shell's manpage converter, [create_manpage_completions.py](https://github.com/fish-shell/fish-shell/blob/master/share/tools/create_manpage_completions.py). |
| 10 | +So you must first install fish shell, See below for installation instructions. |
| 11 | + |
| 12 | +https://github.com/fish-shell/fish-shell |
| 13 | + |
| 14 | +If you do not want to install fish, you can also manually place and run the conversion python script. |
| 15 | + |
| 16 | +## Installation |
| 17 | + |
| 18 | +**Normal:** |
| 19 | + |
| 20 | +Download the binary from [GitHub Releases][release] and drop it in your `$PATH`. |
| 21 | + |
| 22 | +- [Linux][release] |
| 23 | +- [Mac][release] |
| 24 | + |
| 25 | +**Go install:** |
| 26 | + |
| 27 | +```bash |
| 28 | +go install github.com/umlx5h/zsh-manpage-completion-generator@latest |
| 29 | +``` |
| 30 | + |
| 31 | +## Usage |
| 32 | + |
| 33 | +You must first generate fish competion files. |
| 34 | +It generates completion files, usually under folder `$XDG_DATA_HOME/.local/share/fish/generated_completions` |
| 35 | + |
| 36 | +```console |
| 37 | +$ fish -c 'fish_update_completions' |
| 38 | +Parsing man pages and writing completions to /home/dummy/.local/share/fish/generated_completions/ |
| 39 | +``` |
| 40 | + |
| 41 | +Then generate zsh completions from fish completions folder. |
| 42 | +By default, it is generated in folder `$XDG_DATA_HOME/.local/share/zsh/generated_man_completions` |
| 43 | + |
| 44 | +```console |
| 45 | +$ zsh-manpage-completion-generator |
| 46 | +Converting fish completions: /home/dummy/.local/share/fish/generated_completions -> /home/dummy/.local/share/zsh/generated_man_completions |
| 47 | +Completed. converted: 2579/2581, skipped: 142 |
| 48 | +``` |
| 49 | + |
| 50 | +Then add completions folder to your `fpath` in `.zshrc`. |
| 51 | +(It is recommended to place them at the end of the `fpath`, so that human-generated completions such as [zsh-users/zsh-completions](https://github.com/zsh-users/zsh-completions) will be preferred.) |
| 52 | + |
| 53 | +``` |
| 54 | +fpath=( |
| 55 | + $fpath |
| 56 | + $HOME/.local/share/zsh/generated_man_completions |
| 57 | +) |
| 58 | +compinit # This is not necessary if it is called after this. |
| 59 | +``` |
| 60 | + |
| 61 | +You may have to force rebuild zcompdump |
| 62 | +```console |
| 63 | +$ rm -f ~/.zcompdump && compinit |
| 64 | +``` |
| 65 | + |
| 66 | +It is recommended that `compinit` be called only once because of the startup time. |
| 67 | +You can check the number of calls to `compinit` by using `zprof`. |
| 68 | + |
| 69 | +Note that `fpath` must be added before `compinit`. |
| 70 | +If you are using any zsh framework, check where it is adding `fpath` and calling `compinit`. |
| 71 | + |
| 72 | +## Option |
| 73 | + |
| 74 | +The following command line options are supported. |
| 75 | + |
| 76 | +You can change the path to the fish and zsh completions by specifying `-dst` and `-src`. |
| 77 | +The `-clean` option can be specified to remove zsh completion folder before generating them. |
| 78 | +This is useful for removing completions that are no longer needed. |
| 79 | +(Note that the entire `-dst` folder will be deleted.) |
| 80 | + |
| 81 | +```console |
| 82 | +$ zsh-manpage-completion-generator -h |
| 83 | +Usage of zsh-manpage-completion-generator: |
| 84 | + -clean |
| 85 | + CAUTION: remove destination folder before converting |
| 86 | + -dst string |
| 87 | + zsh generated_completions destination folder (default "/home/dummy/.local/share/zsh/generated_man_completions") |
| 88 | + -src string |
| 89 | + fish generated_completions src folder (default "/home/dummy/.local/share/fish/generated_completions") |
| 90 | + -verbose |
| 91 | + verbose log |
| 92 | + -version |
| 93 | + show version |
| 94 | +``` |
| 95 | + |
| 96 | +## Caveat |
| 97 | + |
| 98 | +- Some invalid options may be generated, but there is nothing that can be done about this, as this is also the case with fish. |
| 99 | + |
| 100 | +## Related |
| 101 | + |
| 102 | +- [nevesnunes/sh-manpage-completions](https://github.com/nevesnunes/sh-manpage-completions) |
| 103 | +- [RobSis/zsh-completion-generator](https://github.com/RobSis/zsh-completion-generator) |
| 104 | + |
| 105 | +## License |
| 106 | + |
| 107 | +MIT |
| 108 | + |
| 109 | +[release]: https://github.com/umlx5h/zsh-manpage-completion-generator/releases/latest |
0 commit comments