Created
November 20, 2018 07:05
-
-
Save markhuyong/877aeb2dcedc58d0a3d107c1109945b4 to your computer and use it in GitHub Desktop.
explain shell in command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# explain.sh begins | |
explain () { | |
if [ "$#" -eq 0 ]; then | |
while read -p "Command: " cmd; do | |
curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd" | |
done | |
echo "Bye!" | |
elif [ "$#" -eq 1 ]; then | |
curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$1" | |
else | |
echo "Usage" | |
echo "explain interactive mode." | |
echo "explain 'cmd -o | ...' one quoted command to explain it." | |
fi | |
} | |
explain "${*:1}" |
This is very useful utility.
Pretty similar to having alias cheat='cht.sh'
on .bashrc
and then just e.g. cheat du
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to install
How to use
How to uninstall
refers: