From 2d60d6ccd4ccdb7fc8b2f716da25db205b1da7e7 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Wed, 14 Oct 2015 09:59:11 -0600 Subject: [PATCH 1/2] Adding mankier.com explain() function to explain other commands --- plugins/available/explain.plugin.bash | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 plugins/available/explain.plugin.bash diff --git a/plugins/available/explain.plugin.bash b/plugins/available/explain.plugin.bash new file mode 100644 index 00000000..b2d9593a --- /dev/null +++ b/plugins/available/explain.plugin.bash @@ -0,0 +1,23 @@ +cite about-plugin +about-plugin 'mankier.com explain function to explain other commands' + +# 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/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 +} + +# 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 From 34e9878943eb8c0ffb0cee97bbdfc62d6a720e56 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Fri, 16 Oct 2015 10:11:00 -0600 Subject: [PATCH 2/2] explain: remove comments, add about, example, group, param metadata to explain() --- plugins/available/explain.plugin.bash | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/available/explain.plugin.bash b/plugins/available/explain.plugin.bash index b2d9593a..d57b78e2 100644 --- a/plugins/available/explain.plugin.bash +++ b/plugins/available/explain.plugin.bash @@ -1,8 +1,13 @@ cite about-plugin about-plugin 'mankier.com explain function to explain other commands' -# Add this to ~/.bash_profile or ~/.bashrc explain () { + about 'explain any bash command via mankier.com manpage API' + param '1: Name of the command to explain' + example '$ explain # interactive mode. Type commands to explain in REPL' + example '$ explain 'cmd -o | ...' # one quoted command to explain it.' + group '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" @@ -17,7 +22,3 @@ explain () { 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