mirror of
https://github.com/chubin/cheat.sh.git
synced 2024-12-01 10:44:09 +03:00
added bash function + bash_completion for it (/:bash)
This commit is contained in:
parent
466bc4acef
commit
628f199885
@ -1,9 +1,14 @@
|
|||||||
cht()
|
# if ch is too short for you, replace it with cheat.sh
|
||||||
|
# in the function declaration and in the complete call below
|
||||||
|
|
||||||
|
ch()
|
||||||
{
|
{
|
||||||
|
# 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
|
curl -s cheat.sh/"$1"?style=native
|
||||||
}
|
}
|
||||||
|
|
||||||
_cheatsh_complete_cht()
|
_cheatsh_complete_cheatsh()
|
||||||
{
|
{
|
||||||
local cur opts #prev
|
local cur opts #prev
|
||||||
_get_comp_words_by_ref -n : cur
|
_get_comp_words_by_ref -n : cur
|
||||||
@ -12,12 +17,12 @@ _cheatsh_complete_cht()
|
|||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
opts="$(curl -s cheat.sh/:list)"
|
opts="$(curl -s cheat.sh/:list)"
|
||||||
|
|
||||||
#if [[ "${cur}" == cht ]] ; then
|
#if [[ "${cur}" == ch ]] ; then
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||||
__ltrim_colon_completions "$cur"
|
__ltrim_colon_completions "$cur"
|
||||||
return 0
|
return 0
|
||||||
#fi
|
#fi
|
||||||
}
|
}
|
||||||
|
|
||||||
complete -F _cheatsh_complete_cht cht
|
complete -F _cheatsh_complete_cheatsh ch
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user