Skip to content

Instantly share code, notes, and snippets.

@grmwld
Created March 28, 2016 07:56
Show Gist options
  • Save grmwld/3d5dc4262dd3960904c1 to your computer and use it in GitHub Desktop.
Save grmwld/3d5dc4262dd3960904c1 to your computer and use it in GitHub Desktop.
#!/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 "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment