mirror of
https://github.com/chubin/cheat.sh.git
synced 2025-01-06 04:16:04 +03:00
Add ZSH completion support
This commit is contained in:
parent
5d56fca13e
commit
9af8e6294b
12
README.md
12
README.md
@ -274,6 +274,9 @@ QUERY_OPTIONS="style=native"
|
||||
|
||||
### Tab completion
|
||||
|
||||
|
||||
#### Bash Tab completion
|
||||
|
||||
To activate tab completion support for `cht.sh`, add the `:bash_completion` script to your `~/.bashrc`:
|
||||
|
||||
```
|
||||
@ -282,6 +285,15 @@ To activate tab completion support for `cht.sh`, add the `:bash_completion` scri
|
||||
$ # and add . ~/.bash.d/cht.sh to ~/.bashrc
|
||||
```
|
||||
|
||||
#### ZSH Tab completion
|
||||
|
||||
To activate tab completion support for `cht.sh`, add the `:zsh` script to the fpath in your `~/.zshrc`:
|
||||
|
||||
```
|
||||
$ curl https://cheat.sh/:zsh > ~/.zsh.d/_cht
|
||||
$ echo "fpath=(path/to/zsh-completions/src $fpath)" >> ~/.zshrc
|
||||
$ # Open a new shell to load the plugin
|
||||
|
||||
### Stealth mode
|
||||
|
||||
One of the important properties of any real cheat sheet,
|
||||
|
@ -1,30 +1,22 @@
|
||||
### Temporary disabled zsh support for cheat.sh
|
||||
### This code has to be fixed
|
||||
###
|
||||
### # add this to ~/.zshrc or any other place that will be sourced by your .dotfiles script
|
||||
###
|
||||
### cheat.sh()
|
||||
### {
|
||||
### # replace native with the color scheme you want
|
||||
### # curl cheat.sh/:styles-demo to show the available color schemes
|
||||
### curl -s cheat.sh/"$1"?style=native
|
||||
### }
|
||||
###
|
||||
### _cheatsh_complete_cheatsh()
|
||||
### {
|
||||
### local cur opts #prev
|
||||
### _get_comp_words_by_ref -n : cur
|
||||
###
|
||||
### COMPREPLY=()
|
||||
### prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
### opts="$(curl -s cheat.sh/:list)"
|
||||
###
|
||||
### #if [[ "${cur}" == ch ]] ; then
|
||||
### COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
### __ltrim_colon_completions "$cur"
|
||||
### return 0
|
||||
### #fi
|
||||
### }
|
||||
###
|
||||
### compdef _cheatsh_complete_cheatsh cheat.sh
|
||||
#compdef cht.sh
|
||||
|
||||
__CHTSH_LANGS=($(curl -s cheat.sh/:list))
|
||||
_arguments -C \
|
||||
'--help[show this help message and exit]: :->noargs' \
|
||||
'--shell[enter shell repl]: :->noargs' \
|
||||
'1:Cheat Sheet:->lang' \
|
||||
'*::: :->noargs' && return 0
|
||||
|
||||
if [[ CURRENT -ge 1 ]]; then
|
||||
case $state in
|
||||
noargs)
|
||||
_message "nothing to complete";;
|
||||
lang)
|
||||
compadd -X "Cheat Sheets" ${__CHTSH_LANGS[@]};;
|
||||
*)
|
||||
_message "Unknown state, error in autocomplete";;
|
||||
esac
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user