Why Zsh is Cooler than Your Shell
Upcoming SlideShare
Loading in...5
×
 

Why Zsh is Cooler than Your Shell

on

  • 518,372 views

By Brendon Rapp

By Brendon Rapp
Jaguar Design Studio
January 2013 Cave Lunch

Statistics

Views

Total Views
518,372
Views on SlideShare
479,548
Embed Views
38,824

Actions

Likes
294
Downloads
708
Comments
14

167 Embeds 38,824

https://codeiq.jp 26255
http://drakulavich.blogspot.ru 1887
http://quack1.no-ip.org 1256
https://twitter.com 1039
http://www.wykop.pl 1021
http://idealogeek.fr 1014
http://drakulavich.blogspot.com 818
http://www.redditmedia.com 777
http://cavewall.jaguardesignstudio.com 705
http://erdinote.com 649
http://quack1.me 350
http://www.planet-libre.org 340
http://erdinote.wordpress.com 295
http://elcounp.linux.or.id 290
http://coderkitty.sweetperceptions.com 205
http://moin.neocoin.net 160
http://www.francoistessier.info 138
http://cloud.feedly.com 131
http://leroyetmoi.fr 107
http://appbuntu.com 106
http://www.m4gnus.com 97
http://discourse.u2i.eu 66
http://www.plurk.com 58
http://decebalonprogramming.net 51
http://bigbow.no-ip.org 46
http://busy-fullstack-developer.tumblr.com 42
http://actual-it.info 35
http://beta.idealogeek.fr 34
http://feeds.feedburner.com 32
http://ercansormaz.blogspot.com 32
http://www.ercansormaz.com 30
http://feeds2.feedburner.com 29
http://rss.remitaines.fr 28
http://grandpoohba.tumblr.com 28
http://skopp.koding.com 25
http://feedly.com 23
http://rss.czernai.info 23
http://drakulavich.blogspot.se 23
http://www.feedspot.com 22
http://leed.binuts.fr 22
http://getpocket.com 21
http://www.scoop.it 19
http://ptaxotep.wordpress.com 17
http://new.planet-libre.org 17
https://t.co 17
http://drakulavich.blogspot.de 16
http://feedreader.com 15
http://translate.googleusercontent.com 14
http://inoreader.com 13
http://127.0.0.1 13
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

110 of 14 Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • @Kevin Rowe
    This will simply give the last line
    And yes I know I can do:
    shell$ cat `locate .blah blah |tail blah`
    But that just is too much typing
    What I'm talking about is zsh loading the output lines in variable that I can just call with a few keystrokes
    Are you sure you want to
    Your message goes here
    Processing…
  • @rumcho locate file.abc /a/b/c/file.abc|tail -n 1

    BTW, this is not zsh specific. It should work anywhere.
    Are you sure you want to
    Your message goes here
    Processing…
  • Question for all the zshell gurus:
    Let's say I do:
    --
    shell$ locate file.abc
    /a/b/c/file.abc
    /xyz/file.abc
    /x/y/z/cde/file.abc
    shell$
    --
    Now that I got the prompt back, I'd like to 'cat' the last found file '/x/y/z/cde/file.abc' but I don't want to lift my hand off the keyboard, reach for the mouse, highlight the desired file and copy/paste it at the prompt. I just want to do something like:
    shell$ cat ${???magic???}
    where ${???magic???} would store the last output line of the last command I executed (i.e. the last line of the 'locate file.abc' command)
    Is there such a thing in zshell?
    Are you sure you want to
    Your message goes here
    Processing…
  • @martinknesl94 $winIsFail = Gee.ICant.Understand.Why.Noobs.Cant.Understand.This()
    Are you sure you want to
    Your message goes here
    Processing…
  • Awesome! Thanks for sharing! I just fall in love with Zsh! Hahahah
    Are you sure you want to
    Your message goes here
    Processing…

110 of 14

Post Comment
Edit your comment

    Why Zsh is Cooler than Your Shell Why Zsh is Cooler than Your Shell Presentation Transcript

    • whyZ shell (zsh)is coolerthanyour shell Brendon Rapp - Cave Lunch #1
    • whyZ shell (zsh)is coolerthanyour shell(unless your shell is zsh) Brendon Rapp - Cave Lunch #1
    • (alternate title)she sellsZ shellsby thesea shore
    • Donald KnuthProfessor Emeritus ofComputer Science atStanfordAuthor of The Art ofComputer Programming"Father of algorithmicanalysis"Creator of TeX
    • In 1986, Knuth was asked to write a guestfeature for the "Programming Pearls" column inthe Communications of the ACM journal.The task was to write a program that would:read a file of text, determine the n mostfrequently used words, and print out a sortedlist of those words along with their frequencies.
    • Knuth produced a solution in Pascal that, whenprinted, was about 10 pages in length. It waswell designed, thoroughly commented, andused a novel data structure for managing theword count list.
    • In response, Doug McIlroy wrote a shell scriptthat produced the same output.
    • In response, Doug McIlroy wrote a shell scriptthat produced the same output.McIlroys script was six lines long.
    • Doug McIlroys Shell Scripttr -cs A-Za-z n |tr A-Z a-z |sort |uniq -c |sort -rn |sed ${1}q
    • A brief history of shells1971: Thompson shell ● Ken Thompson, Bell Labs, first Unix shell ● interactive interpreter, not scripting environment1977: 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
    • A brief history of shells1978: 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.21983: 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
    • A brief history of shells1989: 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 syntax1990: Z shell ● most closely resembles Korn shell ● /bin/bash compatibility, drop-in replacement for Bash ● "new" (despite being over 20 years old) ● awesome stuff Ill talk about next
    • Why use zsh?
    • First, a reason thats kind of lame...
    • If youre using Mac OS X...
    • ... your Bash is old!(OS X 10.8.2... and many earlier OS X versions too)
    • 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)
    • Examples of Actual Zsh Awesomeness
    • zsh: cd completion
    • zsh: cd completion
    • zsh: cd completion
    • bash: cd completion
    • bash: cd completion
    • bash: cd completion
    • zsh: git completion
    • zsh: git completion
    • bash: git completion
    • bash: git completionIts possible to get completion for git (and many other commands) in Bashby installing bash-completion package, but the completion is stillrudimentary 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-placeThere may be ways to improve that situation and bring it more in line withzsh, but with zsh, you get it basically out-of-the-box, with a single commandin your .zshrc to enable completions.
    • zsh: path expansion (hit TAB, and then...)
    • zsh: path expansion (... the path is expanded in place, provided there is only one path matching that pattern)
    • zsh: path expansion (If there isnt only one distinct match for the pattern...)
    • zsh: path expansion(... the first TAB will expand up until it hits an ambiguity... )
    • zsh: path expansion (... the next TAB lists the possible matches... )
    • zsh: path expansion (... then TAB begins cycling through the possibilities... )
    • zsh: path expansion (... until you get to the one you want, and hit the Right arrow to "select" it ... )
    • zsh: path expansion (... and then TAB resumes matching through the rest of the path)
    • bash: path expansion? (hit TAB ... nothing)
    • zsh: path replacement (Whoops. I meant /usr/local/share)
    • zsh: path replacement
    • zsh: path replacement (no more "cd ../../../")
    • bash: path replacement?
    • zsh: right promptPROMPT (or PS1): left prompt (like bash)RPROMPT (or RPS1): right prompt!
    • zsh: right prompt
    • zsh: spelling correction
    • zsh: spelling correction
    • zsh: spelling correction
    • zsh: aliasesNormal aliases:alias ls=ls --color=auto
    • zsh: aliasesGlobal aliases - appear anywhere in commandstringalias -g gp=| grep -i% ps ax gp ruby=> ps ax | grep -i ruby
    • zsh: aliasesSuffix aliases - "Open With..."alias -s rb=vimalias -s log="less -MN"alias -s html=chromium% user.rb=> vim user.rb% development.log=> less -MN development.log% index.html=> chromium index.html
    • zsh: extended globbingNormal globbed search
    • zsh: extended globbingExtended globbed search: **/ = recursive
    • zsh: environment variable editing
    • zsh: programmable file renaming
    • zsh-history-substring-searchDown arrow = cycle through command history
    • zsh-history-substring-searchType part of command and hit up arrow, cycle through onlycommands that begin with that string
    • zsh-syntax-highlightingHighlights valid commands in green, invalid commands inredSupports shell commands as well as executables in $PATH
    • oh-my-zsh
    • 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 destinationsAnd, apparently, plenty of other stuff deeper than Ivegotten so far.
    • The End Go 49ers