]> arthur.barton.de Git - ax-zsh.git/blob - default_plugins/cheat/cheat.zshrc
Add new "nodejs" plugin
[ax-zsh.git] / default_plugins / cheat / cheat.zshrc
1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # cheat: Setup https://cht.sh
3
4 # Don't overwrite a real "cheat" command!
5 (( $+commands[cheat] )) && return
6
7 function cheat() {
8         if (( $+commands[cht.sh] )); then
9                 if [[ $# -eq 0 ]]; then
10                         CHTSH_QUERY_OPTIONS="style=monokai" cht.sh --shell
11                 else
12                         CHTSH_QUERY_OPTIONS="style=monokai" cht.sh "$@" \
13                          | ${PAGER:-less}
14                 fi
15                 return $?
16         fi
17
18         url="https://cht.sh/$@?style=monokai"
19
20         if (( $+commands[curl] )); then
21                 curl -s "$url" | ${PAGER:-less}
22         elif (( $+commands[wget] )); then
23                 wget -qO - "$url" | ${PAGER:-less}
24         else
25                 echo "Neither cht.sh(1), curl(1) nor wget(1) found!" >&2
26                 return 1
27         fi
28 }