• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..24-Oct-2021-

fish-tools/H24-Oct-2021-2,0811,661

include/H24-Oct-2021-8267

src/H24-Oct-2021-142126

templates/H24-Oct-2021-9579

.gitignoreH A D24-Oct-2021107 108

LICENSE.GPL2H A D24-Oct-202114.7 KiB279236

LICENSE.MITH A D24-Oct-20211 KiB2217

MakefileH A D24-Oct-2021315 2114

README.mdH A D24-Oct-20212.3 KiB5735

fish-completions.lH A D24-Oct-20213.1 KiB159131

run.shH A D24-Oct-20213.2 KiB130108

README.md

1# sh-manpage-completions
2
3Automatically generate bash and zsh completions from man pages.
4
5Uses [fish-shell](https://github.com/fish-shell/fish-shell)'s `create_manpage_completions.py` to parse the pages, then converts the resulting fish completions.
6
7## Example
8
9```
10./run.sh /usr/share/man/man1/tar.1.gz
11```
12
13You can then take the files from `completions/$shell/` and use them according to your configuration:
14
15- **Bash**: Source them in an initialization file (e.g. `~/.bashrc`)
16- **Zsh**: Add them to a directory in `$fpath`
17
18## Limitations
19
20Bash doesn't support descriptions in completions. There has been some [discussion about workarounds](https://stackoverflow.com/questions/7267185/bash-autocompletion-add-description-for-possible-completions). Two different strategies were implemented:
21
221. Separate descriptions
23
24Consists on printing the completions with descriptions, before bash displays the completions again. It results in redundancy but doesn't break tab behaviour. Descriptions can be omitted like so:
25
26```
27BASH_NO_DESCRIPTIONS=1 ./run.sh /usr/share/man/man1/tar.1.gz
28```
29
302. Filter through a selector
31
32You can use a fuzzy selector to extract the right option, containg both the completion and its description. No redundancy, but relies on an external application. Can be used like so:
33
34```
35BASH_USE_SELECTOR=1 ./run.sh /usr/share/man/man1/tar.1.gz
36```
37
38Uses [fzf](https://github.com/junegunn/fzf) by default. You can pass another one, optionally with an argument that takes the current input as a query, filtering down the results:
39
40```
41BASH_USE_SELECTOR=1 SELECTOR=fzy SELECTOR_QUERY='-q' ./run.sh /usr/share/man/man1/tar.1.gz
42```
43
44## Related Work
45
46- Built-in parsing of options output by `--help`:
47    - **Bash**: `complete -F _longopt`
48    - **Zsh**: `compdef _gnu_generic`
49- [GitHub \- RobSis/zsh\-completion\-generator: Plugin that generates completion functions automatically from getopt\-style help texts](https://github.com/RobSis/zsh-completion-generator)
50- [GitHub \- Aloxaf/fzf\-tab: Replace zsh's default completion selection menu with fzf!](https://github.com/Aloxaf/fzf-tab)
51
52## License
53
54Files in `fish-tools` were taken from fish-shell's source code, which is released under the GNU General Public License, version 2 (see LICENSE.GPL2).
55
56The remaining source code is released under the MIT License (see LICENSE.MIT).
57