]> arthur.barton.de Git - ax-zsh.git/commitdiff
cheat: Don't shadow real command (if any), and use pagination
authorAlexander Barton <alex@barton.de>
Sun, 3 Feb 2019 13:33:25 +0000 (14:33 +0100)
committerAlexander Barton <alex@barton.de>
Sun, 3 Feb 2019 13:33:25 +0000 (14:33 +0100)
default_plugins/cheat/cheat.zshrc

index c36603211360ae272921f2ecaa443619eaeaedb2..bfec74789441f60cc3fb727547b099316875493b 100644 (file)
@@ -1,13 +1,16 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
 # cheat: Setup http://cheat.sh
 
+# Don't overwrite a real "cheat" command!
+(( $+commands[cheat] )) && return
+
 function cheat() {
        url="http://cheat.sh/$@?style=monokai"
 
        if (( $+commands[curl] )); then
-               curl "$url"
+               curl -s "$url" | ${PAGER:-less}
        elif (( $+commands[wget] )); then
-               wget -qO - "$url"
+               wget -qO - "$url" | ${PAGER:-less}
        else
                echo "Neither curl(1) nor wget(1) found!" >&2
                return 1