Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
Why zsh is Cooler than Your Shell
Next
Download to read offline and view in fullscreen.

622

Share

Why Zsh is Cooler than Your Shell

Download to read offline

By Brendon Rapp
Jaguar Design Studio
January 2013 Cave Lunch

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Why Zsh is Cooler than Your Shell

  1. 1. why Z shell (zsh) is cooler than your shell Brendon Rapp - Cave Lunch #1
  2. 2. why Z shell (zsh) is cooler than your shell (unless your shell is zsh) Brendon Rapp - Cave Lunch #1
  3. 3. (alternate title) she sells Z shells by the sea shore
  4. 4. Donald Knuth Professor Emeritus of Computer Science at Stanford Author of The Art of Computer Programming "Father of algorithmic analysis" Creator of TeX
  5. 5. In 1986, Knuth was asked to write a guest feature for the "Programming Pearls" column in the Communications of the ACM journal. The task was to write a program that would: read a file of text, determine the n most frequently used words, and print out a sorted list of those words along with their frequencies.
  6. 6. Knuth produced a solution in Pascal that, when printed, was about 10 pages in length. It was well designed, thoroughly commented, and used a novel data structure for managing the word count list.
  7. 7. In response, Doug McIlroy wrote a shell script that produced the same output.
  8. 8. In response, Doug McIlroy wrote a shell script that produced the same output. McIlroy's script was six lines long.
  9. 9. Doug McIlroy's Shell Script tr -cs A-Za-z 'n' | tr A-Z a-z | sort | uniq -c | sort -rn | sed ${1}q
  10. 10. A brief history of shells 1971: Thompson shell ● Ken Thompson, Bell Labs, first Unix shell ● interactive interpreter, not scripting environment 1977: Bourne shell ● scripting language ● Version 7 Unix, PDP-11 ● 1984: The UNIX Programming Environment, Kernighan & Pike ● The shell of commercial Unixes ○ System V, AIX, HP-UX, SCO, Solaris, SunOS ○ Still the default on some of these (that are still alive) ● /bin/sh ○ compatibility mode in modern shells ○ symlink or hard link to compatible shells in modern Unixes
  11. 11. A brief history of shells 1978: C shell ● BSD Unix ● More "C-like" scripting syntax (kinda) ● Command history ● Aliasing ● tcsh - newer C shell, default on FreeBSD, and OS X systems 10.0-10.2 1983: Korn shell ● Bell Labs (AT&T) ● Proprietary until 2000 ● vi and emacs editing modes ● Lots of C shell features ● "middle road" between Bourne and C shell ● pdksh - default on OpenBSD
  12. 12. A brief history of shells 1989: Bourne Again shell (bash) ● GNU, GPL ● first legitimate Free shell (/bin/sh compatible) ○ shells like ksh and csh became Free only much later on ● standard shell for Linux distros, Mac OS X 10.3+ ● TAB completion ● extended scripting syntax 1990: Z shell ● most closely resembles Korn shell ● /bin/bash compatibility, drop-in replacement for Bash ● "new" (despite being over 20 years old) ● awesome stuff I'll talk about next
  13. 13. Why use zsh?
  14. 14. First, a reason that's kind of lame...
  15. 15. If you're using Mac OS X...
  16. 16. ... your Bash is old! (OS X 10.8.2... and many earlier OS X versions too)
  17. 17. OS X: GPL Wasteland ● no GPLv3 on OS X ● OS X bash: final version released as GPLv2 ● Homebrew has latest Bash (but many use situation as an excuse to try zsh instead)
  18. 18. Examples of Actual Zsh Awesomeness
  19. 19. zsh: cd completion
  20. 20. zsh: cd completion
  21. 21. zsh: cd completion
  22. 22. bash: cd completion
  23. 23. bash: cd completion
  24. 24. bash: cd completion
  25. 25. zsh: git completion
  26. 26. zsh: git completion
  27. 27. bash: git completion
  28. 28. bash: git completion It's possible to get completion for git (and many other commands) in Bash by installing bash-completion package, but the completion is still rudimentary compared to zsh: ● no cycling through options with repeated tabs ● no accompanying info with commands, just a list ● breaks to new prompt line on each tab instead of updating in-place There may be ways to improve that situation and bring it more in line with zsh, but with zsh, you get it basically out-of-the-box, with a single command in your .zshrc to enable completions.
  29. 29. zsh: path expansion (hit TAB, and then...)
  30. 30. zsh: path expansion (... the path is expanded in place, provided there is only one path matching that pattern)
  31. 31. zsh: path expansion (If there isn't only one distinct match for the pattern...)
  32. 32. zsh: path expansion (... the first TAB will expand up until it hits an ambiguity... )
  33. 33. zsh: path expansion (... the next TAB lists the possible matches... )
  34. 34. zsh: path expansion (... then TAB begins cycling through the possibilities... )
  35. 35. zsh: path expansion (... until you get to the one you want, and hit the Right arrow to "select" it ... )
  36. 36. zsh: path expansion (... and then TAB resumes matching through the rest of the path)
  37. 37. bash: path expansion? (hit TAB ... nothing)
  38. 38. zsh: path replacement (Whoops. I meant /usr/local/share)
  39. 39. zsh: path replacement
  40. 40. zsh: path replacement (no more "cd ../../../")
  41. 41. bash: path replacement?
  42. 42. zsh: right prompt PROMPT (or PS1): left prompt (like bash) RPROMPT (or RPS1): right prompt!
  43. 43. zsh: right prompt
  44. 44. zsh: spelling correction
  45. 45. zsh: spelling correction
  46. 46. zsh: spelling correction
  47. 47. zsh: aliases Normal aliases: alias ls='ls --color=auto'
  48. 48. zsh: aliases Global aliases - appear anywhere in command string alias -g gp='| grep -i' % ps ax gp ruby => ps ax | grep -i ruby
  49. 49. zsh: aliases Suffix aliases - "Open With..." alias -s rb=vim alias -s log="less -MN" alias -s html=chromium % user.rb => vim user.rb % development.log => less -MN development.log % index.html => chromium index.html
  50. 50. zsh: extended globbing Normal globbed search
  51. 51. zsh: extended globbing Extended globbed search: **/ = recursive
  52. 52. zsh: environment variable editing
  53. 53. zsh: programmable file renaming
  54. 54. zsh-history-substring-search Down arrow = cycle through command history
  55. 55. zsh-history-substring-search Type part of command and hit up arrow, cycle through only commands that begin with that string
  56. 56. zsh-syntax-highlighting Highlights valid commands in green, invalid commands in red Supports shell commands as well as executables in $PATH
  57. 57. oh-my-zsh
  58. 58. Other zsh bullet points ● Simple configuration style ● Shared history ○ simple & fast, requires some monkeying to replicate in bash ● Lots of additions for shell scripting ● Output redirection to multiple destinations And, apparently, plenty of other stuff deeper than I've gotten so far.
  59. 59. The End Go 49ers
  • lborgav

    Dec. 27, 2020
  • shashisatya

    Jun. 1, 2020
  • MichaeldaCostaSilva

    Apr. 7, 2020
  • tomechval

    Apr. 4, 2020
  • chenkaie

    Jan. 19, 2020
  • asargent

    Oct. 11, 2019
  • ramblezeus

    Aug. 27, 2019
  • jjxdev90

    Aug. 22, 2019
  • RasoolZiafaty

    Aug. 19, 2019
  • TheRohitGupta

    Mar. 2, 2019
  • andreeduardoperezalvarez

    Feb. 19, 2019
  • MicheleSpinella

    Jan. 18, 2019
  • justinhampton5

    Jan. 3, 2019
  • MohamedMeabed

    Dec. 6, 2018
  • PedroPatraquim

    Oct. 29, 2018
  • IsmaelPaiva

    Aug. 25, 2018
  • CyrilAttie

    Aug. 14, 2018
  • FernandaDvila2

    Aug. 9, 2018
  • adkdev

    Aug. 3, 2018
  • cheuk123154

    Jul. 9, 2018

By Brendon Rapp Jaguar Design Studio January 2013 Cave Lunch

Views

Total views

1,064,299

On Slideshare

0

From embeds

0

Number of embeds

228,433

Actions

Downloads

1,547

Shares

0

Comments

0

Likes

622

×