File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ Rules & Behavior
3838 return a Promise [boolean]
3939```
4040
41- * bash- completion shortcuts for commands and options.
41+ * generate completion scripts for Bash and Zsh for your command
4242* and [ tons more] ( /docs/api.md ) .
4343
4444## Installation
Original file line number Diff line number Diff line change @@ -354,8 +354,25 @@ discussion of the advanced features exposed in the Command API.
354354Enable bash/zsh-completion shortcuts for commands and options.
355355
356356` cmd ` : When present in ` argv._ ` , will result in the ` .bashrc ` or ` .zshrc ` completion script
357- being outputted. To enable bash/zsh completions, concat the generated script to your
358- ` .bashrc ` or ` .bash_profile ` (or ` .zshrc ` for zsh).
357+ being outputted.
358+
359+ To enable bash/zsh completions, you can either:
360+ 1 . Concat the generated script to your
361+ ` .bashrc ` or ` .bash_profile ` (or ` .zshrc ` for zsh).
362+
363+ e.g. ` ./command completion > ~/.bashrc `
364+
365+ 2 . If you have ` bash-completion ` installed, write it to a file in
366+ ` $XDG_DATA_HOME/bash-completion ` (or ` ~/.local/share/bash-completion ` ),
367+ with the same name as the command.
368+
369+ e.g. ` ./command completion > ${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/command `
370+
371+ 3 . For Zsh, write it to a file in your ` $fpath ` named
372+ ` _{{app_name}}_yargs_completions ` where ` {{app_name}} ` is your
373+ command name.
374+
375+ e.g. ` ./command completion > /usr/local/share/zsh/site-functions/_command_yargs_completions `
359376
360377` description ` : Provide a description in your usage instructions for the command
361378that generates the completion scripts.
Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ _{{app_name}}_yargs_completions()
4949 _default
5050 fi
5151}
52- compdef _{{app_name}}_yargs_completions {{app_name}}
52+ if [[ "'\${zsh_eval_context[-1]}" == "loadautofunc" ]]; then
53+ _{{app_name}}_yargs_completions "$@"
54+ else
55+ compdef _{{app_name}}_yargs_completions {{app_name}}
56+ fi
5357###-end-{{app_name}}-completions-###
5458` ;
You can’t perform that action at this time.
0 commit comments