]> arthur.barton.de Git - ax-zsh.git/blob - default_plugins/cheat/cheat.zshrc
cheat: Don't shadow real command (if any), and use pagination
[ax-zsh.git] / default_plugins / cheat / cheat.zshrc
1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # cheat: Setup http://cheat.sh
3
4 # Don't overwrite a real "cheat" command!
5 (( $+commands[cheat] )) && return
6
7 function cheat() {
8         url="http://cheat.sh/$@?style=monokai"
9
10         if (( $+commands[curl] )); then
11                 curl -s "$url" | ${PAGER:-less}
12         elif (( $+commands[wget] )); then
13                 wget -qO - "$url" | ${PAGER:-less}
14         else
15                 echo "Neither curl(1) nor wget(1) found!" >&2
16                 return 1
17         fi
18 }