Bash Geekcamp

  • View
    353

  • Download
    3

Embed Size (px)

DESCRIPTION

hack bash into something that addresses the concerns of Don Norman and Jef Raskin to make your bash smarter than you are.

Text of Bash Geekcamp

  • 1. Towards a Smarter Bash

2. HCI 3. Human 4. Computer 5. 6. Barbara Blackburn 7. 200 wpm = 200 * 5 * 8 / 60 = 133 bits/s 8. Towards a Smarter Bash 9. Howard Stephen Berg 10. 25,000 wpm 11. he's a freak 12. 2000 wpm = 1.3 kbits/s 13. Towards a Smarter Bash 14. V22.bis = Blazing Fast 15. For 1988 16. 2:rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrsAXrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr 2rXXXXXXXXXXXXXXXXXXXXXXXXXXXXX5@; B2222XXXXXXXXXXXXX22XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXhi 2sXXXXXXXXXXXXXXXXXXXXXXXXXXX2h@@A,@@#A92XXXXXXXXXX2Xh22XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX3i 2rXX22222222222222222252222222S#@@@@@@922222222225ShX3@S2222222222222222222222X22222222222222222222222222XXi 2rX2222222222222222225HA522222Ss3B##A5:2X222222HMH@522222222222222222S2##X2222222222222222222222222222Xi 2rX22222222222222222iBX,A2S5525Ssrrri;iX22222Xi5@@@@@@@@S222222222222225##@#i522222222222222222222222222Xi 2rX2222222222222222XB@S G#Hh9525SSSSSr922222X2;i2#@@@@#2S222222222225525@@@si#3522222222222222222222222222Xi 2rX22222222222222225@@@@@@@Hh2222223ri3222223ri2isS22isS22222225555A#ASiG@@@@@#A52222222222222222222222222Xi 2rX2222222222222222SiH@@@@M;sX222223rXX2222X5r925Ssssi5222222223h2H@iis2B##ASh52222222222222222222222222Xi 2rX22222222222222225issiiir;X22222X5r9222223rSX225SS2222222225AM@@@,5@M5isrs;:s522222222222222222222222222Xi 2rX222222222222222225Siii2rs322222Xsi3222222r3X25h#A355522222XrX@@@@@@#SS55r;XX222222222222222222222222222Xi 2rX2222222222222222222222Xr2X222223r5X22223si322i@; &hh322222Xr;2H#MA2i52Xrs9X2222222222222222222222222222Xi 2rX2222222222222222222222Xr32222223r2X22223rXX22#@#;M@@MA5222Xs;Srrrri523rs9X22222222222222222222222222222Xi 2rX222222222222222222222X5r9222222Xr32222XSr922i&@@@@@@A:2222XirXSSS5223sr9X222222222222222222222222222222Xi 2rX222222222222222222222Xir922222X2r322223riX222iSGHHG2s;X2223ssX22222X5r325222222222222222222222222222222Xi 2rX2222222222222222222223si322222X5r922223rXX225SisrrrSss32223siX22252S:hHMAS22222222222222222222222222222Xi 2rX2222222222222222222223si322222XSr9222X5r9222255SS553r5X2229r5X22XAAHh3 ;@i22222222222222222222222222222Xi 2rX2222222222222222222223riX22222XSr3222Xis92222222222Xr32222XrX22XsA@@@M5@@AS2222222222222222222222222222Xi 2rX2222222222222222222229riX22222XSr32223rSX222222222Xir9222X5r922X;iA@@@@@@XS2222222222222222222222222222Xi 2rX2222222222222222222223si322222X5r92223r2X2222222223r5X2223si3225;3:ihG95iS22222222222222222222222222222Xi 2rX2222222222222222222223is32222X32rh3X3Xr3X2222222222r322223r2X2XssX;SsrsiS2225X2222222222222222222222222Xi 2rX222222222222222222222Xir9X9GAA&Gs&hGA9SBA&h3XX2223si3222X5r9229r25r355522555&A#SS2222222222222222222222Xi 2rX222222222222222222222X5sH9i;..:r59&AG3X3rXX2223ri3222r&2rXX222292#, #&X5222222222222222222222Xi 2rX222222222222222222222h&:.,s9H2ihX222XrXX2XiiH. hX222##@@AA@@#i222222222222222222222Xi 2rX22222222222222222222&5;hHhX2Xis9223i5&h22XiiM@@@@@#55222222222222222222222Xi 2rX2222222222222222222Gr,3H99;2X223;:B322Xrri5GAh5sS2222222222X22222222222Xi 2rX222222222222222222Gr,:H2s922XX;#9XXX;XSirrri52222222222253X222222222Xi 2rX2222222222222222235..iA322&;5HAH5XA32555222222222222X 53222222222Xi 2rX22222222222222222G:3GX2A,,.:r2A9X22XXXXX22222XX ;AX22222222Xi 2rX2222222222222222Gr:,AX93;h&&G3XGAA9XXXXM: :HX22222222Xi 2rX2222222222222222&.,,XG9iMH;;3AA&3::HX22222222Xi 2rX222222222222222X3:.,SH5i#ASA222222222Xi 2rX2222222222222223A5.::sMrX&M#r.B9222222222Xi 2rX2222222222222223#G;.,,.:rAsh9GB#&5r:,,..H&X222222222Xi 2rX222222222222222X9A2:SA3r.:;;..,.,.233X3GhsH@@@@@@,;,r#AX2222222222Xi 2rX2222222222222222X3A5.rXGXs:.;.:5M9X39;iH&&&AB@H@@M2;.,;X##GX22222222222Xi 2rX22222222222222222X9A#G;;i3hhX5s;:,. .: .....,;,.rAHXSr393X9AM, r@AAB#@@###@@#A3X222222222222Xi 2rX22222222222222222XX9GA##&s..,,,,..,...r.... ;,.;9iHAA&3s,#G339hGAAAAGh3X22222222222222Xi 2rX222222222222222222XXX9h&H###&S;.:..;..:,:#GX222XXXXXXX22222222222222222Xi 2rX222222222222222222222XX39hGAH####AXs;;.,.:, .s#GX2222222222222222222222222222Xi 2rX222222222222222222222222XXX39hG&AB#@@##BG2i;:;... .;H#GX22222222222222222222222222222Xi 2rXG9XX2X2S222222G9XX2X2S22222XGh333h3Xh&AHM#@@@##MAX5isr,,;:,...,:r3#@#&XX2X2S222222G9XX2X2S222222G9X2X3i 2iA;iH32S2ASi529&;iH32S2ASi529G;iH32S2H5S23AHrX#HA&B@MB##@@2H@@BAM@MB#MBA;SA32S2ASi52hG:SA32S2ASi52hh:SH325S 5.s2&@@@h5i:r2A@@@h5i:r2A@@@h5s:.s3H@@@A35;,2H#@@@HXi:s2A@@@h5s:sXA@@@h5s:sXHH 3, ..:3@@@@@@@G: ..:3@@@@@@@G, ..:3@@@@@@@h, ..:3@@@@@@@G:..,:h@@@@@@@h, ..:9@@@@@@@h, ..:9@@@@@@@h, ..:9@@M @M#####MBBBBBM#######MBBBBBM#######MBBBBBM#######MBBBBBM#######MBBBBBM#######MBBBBBM#######MBBBBBM#######MBH 17. Other Criticisms? 18. Towards a Smarter Bash 19. 20. The Truth about UNIX:the user interface is horrid (1981) 21. Inconsistent Syntax & Usage Names do not map to Functionality Feedback only occurs on Error High Cognitive Load 22. He was absolutely correct 23. For 1981. 24. Bash 4.0 25. file.new file.delete file.properties directory.new directory.delete directory.properties ... 26. alias file.new=touch aliasfile.delete=rm alias file.properties=stat alias directory.new=mkdir alias directory.delete=rmdir alias directory.properties=stat ... 27. Mnemonics = Bash Completion 28. Alert Only On Error He was wrong ;) 29. Written by Monkeys on Crack? Snopes says True. 30. 31. 32. A computer shall not harm your work or, through inactivity, allow your work to come to harm. 33. function rm() { mv $* ${TMP_DIR}/. } set -C 34. A computer shall not waste your time or require you to do more work than is strictly necessary 35. Shannon's Law bits/s = frequency * log (1+S/N) N = our typing error rate 36. shopt -s dirspellshopt -s cdspell set completion-ignore-case on 37. To get any lazier,we need to do some real work 38. Huffman Coding Vary storage size inverselywith frequency 39. sort .bash_history |awk '{ print $1 }' |uniq -c | sort -rn | less Create tiny aliasesfor the most common 40. me$ cd /var/tmp me$ ls 41. cd() { builtin cd "$@" # list first bunch of entries directory.contents.wide | head} 42. me$ chmod 0 lamers_file me$ ls -l lamers_file 43. [[ ${PS1} = ]] && return file_change() { IFS= $@ shift for f in "$*" ; do if file.is_file "${f}"; then file.properties "${f}" fi done } 44. mv(){ file_changecommand mv"$@"; } chmod() { file_changecommand chmod "$@"; } chown() { file_changecommand chown "$@"; } touch() { file_changecommand touch "$@"; } 45. Smart Prompts know that attention is precious 46. Seeing is believing? 47. sane_prompt() { export PROMPT_LAST_CMD_EXIT_CODE=$?history -aprompt_screen_shelltitlelocal pkts=$( prompt_pad${TEXT_RED} prompt_network_loss ) # wifi, directory size # SVN/CVS/GIT repo status # disk usage, cpu usage, PS1="${hms}${box}${disk}${cpu}${wifi}${pkts}${dirsize}${repo}${err}${wd}" [[ ${#PS1} -gt ${PROMPT_MAX_LENGTH} ]] &&PS1="${PS1} " export PS1="${PS1}${sigil}${TEXT_BLACK} " export PROMPT_PREVIOUS_TIME=${SECONDS} } export PROMPT_COMMAND=sane_prompt 48. What about the Third Law? 49. sane_prompt() { ... # disabled by operator? [[ -e ${PROMPT_KILL_FILE} ]] && return # box too busy, be nice local load=$( cpu_usage_as_int ) [[ ${load} -gt ${PROMPT_LOAD_MAX} ]] && {echo CPU LOAD ABOVE ${PROMPT_LOAD_MAX}return} ... } 50. 2:rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrsAXrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr 2rXXXXXXXXXXXXXXXXXXXXXXXXXXXXX5@; B2222XXXXXXXXXXXXX22XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXhi 2sXXXXXXXXXXXXXXXXXXXXXXXXXXX2h@@A,@@#A92XXXXXXXXXX2Xh22XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX3i 2rXX22222222222222222252222222S#@@@@@@922222222225ShX3@S2222222222222222222222X22222222222222222222222222XXi 2rX2222222222222222225HA522222Ss3B##A5:2X222222HMH@522222222222222222S2##X2222222222222222222222222222Xi 2rX22222222222222222iBX,A2S5525Ssrrri;iX22222Xi5@@@@@@@@S222222222222225##@#i522222222222222222222222222Xi 2rX2222222222222222XB@S G#Hh9525SSSSSr922222X2;i2#@@@@#2S222222222225525@@@si#3522222222222222222222222222Xi 2rX22222222222222225@@@@@@@Hh2222223ri3222223ri2isS22isS22222225555A#ASiG@@@@@#A52222222222222222222222222Xi 2rX2222222222222222SiH@@@@M;sX222223rXX2222X5r925Ssssi5222222223h2H@iis2B##ASh52222222222222222222222222Xi 2rX22222222222222225issiiir;X22222X5r9222223rSX225SS2222222225AM@@@,5@M5isrs;:s522222222222222222222222222Xi 2rX222222222222222225Siii2rs322222Xsi3222222r3X25h#A355522222XrX@@@@@@#SS55r;XX222222222222222222222222222Xi 2rX2222222222222222222222Xr2X222223r5X22223si322i@; &hh322222Xr;2H#MA2i52Xrs9X2222222222222222222222222222Xi 2rX2222222222222222222222Xr32222223r2X22223rXX22#@#;M@@MA5222Xs;Srrrri523rs9X22222222222222222222222222222Xi 2rX222222222222222222222X5r9222222Xr32222XSr922i&@@@@@@A:2222XirXSSS5223sr9X222222222222222222222222222222Xi 2rX222222222222222222222Xir922222X2r322223riX222iSGHHG2s;X2223ssX22222X5r325222222222222222222222222222222Xi 2rX2222222222222222222223si322222X5r922223rXX225SisrrrSss32223siX22252S:hHMAS22222222222222222222222222222Xi 2rX2222222222222222222223si322222XSr9222X5r9222255SS553r5X2229r5X22XAAHh3 ;@i22222222222222222222222222222Xi 2rX2222222222222222222223riX22222XSr3222Xis92222222222Xr32222XrX22XsA@@@M5@@AS2222222222222222222222222222Xi 2rX2222222222222222222229riX22222XSr32223rSX222222222Xir9222X5r922X;iA@@@@@@XS2222222222222222222222222222Xi 2rX2222222222222222222223si322222X5r92223r2X2222222223r5X2223si3225;3:ihG95iS22222222222222222222222222222Xi 2rX2222222222222222222223is32222X32rh3X3Xr3X2222222222r322223r2X2XssX;SsrsiS2225X2222222222222222222222222Xi 2rX222222222222222222222Xir9X9GAA&Gs&hGA9SBA&h3XX2223si3222X5r9229r25r355522555&A#SS2222222222222222222222Xi 2rX222222222222222222222X5sH9i;..:r59&AG3X3rXX2223ri3222r&2rXX222292#, #&X5222222222222222222222Xi 2rX222222222222222222222h&:.,s9H2ihX222