Last active
September 18, 2021 15:04
-
-
Save jacksonp/9c2f547434b7d78d1b62 to your computer and use it in GitHub Desktop.
Explaining Shell Commands in Bash
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
# Add this to ~/.bash_profile or ~/.bashrc | |
explain () { | |
if [ "$#" -eq 0 ]; then | |
while read -p "Command: " cmd; do | |
curl -Gs "https://www.mankier.com/api/v2/explain/?cols="$(tput cols) --data-urlencode "q=$cmd" | |
done | |
echo "Bye!" | |
elif [ "$#" -eq 1 ]; then | |
curl -Gs "https://www.mankier.com/api/v2/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 | |
} | |
# Update 26-03-2015. If using this command gives no output, see if running a simple fetch causes this error: | |
# $ curl https://www.mankier.com | |
# curl: (35) Cannot communicate securely with peer: no common encryption algorithm(s). | |
# If so, try specifying a cipher in the curl commands: curl --ciphers ecdhe_ecdsa_aes_128_sha |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script for Fish shell: https://github.com/eg0r/scripts/blob/master/fish/explain.fish