Cheatsheets

Updated: Jan 23, 2020 by Pradeep Gowda.

I was lucky to first be introduced to man pages by someone who often just called them “manuals” and (to my best recollection) explained them by telling me “Manuals are to be read, top to bottom, contemplated, and maybe read again, before you act.” Thus I was never under the delusion that man pages were, or should strive to be, How-To’s of some sort. This TLDR tool definitely needs to exist, but in conjunction with man pages, not as a replacement. Manuals should continue to exist in a form that explores and explains the depths of a utility or command in whatever length that might require. I will make adequate use of both. – HNUSER:chao-


Some handy shell functions (by the HN users):

  cheat() { 
   curl "http://cheat.sh/$1"
  }

  man2txt() {
    man "$1" | col -bx
  }

  manflags(){
    man "$1" | awk '{$1=$1;print}' | grep "^\-"
  } #man pages just the flags more or less, captures some extra 

  ubuman() { 
   w3m -dump "https://manpages.ubuntu.com/manpages/bionic/en/man1/"$1".1.html"
  } # ubuntu web manpages note bionic, update with do release up

  ubumanflags() { 
   w3m -dump "https://manpages.ubuntu.com/manpages/bionic/en/man1/$1.1.html" | \
   awk '{$1=$1;print}' | grep "^\-"
  } # ubuntu web manpages

  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
  }

  tldr-web() {
   w3m -dump "https://raw.githubusercontent.com/tldr-pages/tldr/master/pages/common/$1.md"
   w3m -dump "https://raw.githubusercontent.com/tldr-pages/tldr/master/pages/linux/$1.md"
  }

# notetoself: check ```info``` check ```help``` check ```apropos``` check ```whatis```