SlideShare una empresa de Scribd logo
1 de 60
Descargar para leer sin conexión
why
Z      shell              (zsh)
is cooler
than
your shell
    Brendon Rapp - Cave Lunch #1
why
Z      shell                  (zsh)
is cooler
than
your shell
(unless your shell is zsh)

        Brendon Rapp - Cave Lunch #1
(alternate   title)

she sells
Z shells
by the
sea shore
Donald Knuth
Professor Emeritus of
Computer Science at
Stanford

Author of The Art of
Computer Programming

"Father of algorithmic
analysis"

Creator of TeX
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.
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.
In response, Doug McIlroy wrote a shell script
that produced the same output.
In response, Doug McIlroy wrote a shell script
that produced the same output.

McIlroy's script was six lines long.
Doug McIlroy's Shell Script
tr -cs A-Za-z 'n' |
tr A-Z a-z |
sort |
uniq -c |
sort -rn |
sed ${1}q
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
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
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
Why use zsh?
First, a reason that's
   kind of lame...
If you're 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 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.
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 isn't 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 prompt
PROMPT (or PS1): left prompt (like bash)

RPROMPT (or RPS1): right prompt!
zsh: right prompt
zsh: spelling correction
zsh: spelling correction
zsh: spelling correction
zsh: aliases
Normal aliases:

alias ls='ls --color=auto'
zsh: aliases
Global aliases - appear anywhere in command
string

alias -g gp='| grep -i'

% ps ax gp ruby
=> ps ax | grep -i ruby
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
zsh: extended globbing




Normal globbed search
zsh: extended globbing




Extended globbed search: **/ = recursive
zsh: environment variable editing
zsh: programmable file renaming
zsh-history-substring-search




Down arrow = cycle through command history
zsh-history-substring-search




Type part of command and hit up arrow, cycle through only
commands that begin with that string
zsh-syntax-highlighting




Highlights valid commands in green, invalid commands in
red

Supports 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 destinations

And, apparently, plenty of other stuff deeper than I've
gotten so far.
The End




          Go 49ers

Más contenido relacionado

La actualidad más candente

BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)Brendan Gregg
 
Apache Spark At Scale in the Cloud
Apache Spark At Scale in the CloudApache Spark At Scale in the Cloud
Apache Spark At Scale in the CloudDatabricks
 
BPF: Tracing and more
BPF: Tracing and moreBPF: Tracing and more
BPF: Tracing and moreBrendan Gregg
 
A Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQLA Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQLDatabricks
 
Introduction to DPDK
Introduction to DPDKIntroduction to DPDK
Introduction to DPDKKernel TLV
 
Performance Wins with BPF: Getting Started
Performance Wins with BPF: Getting StartedPerformance Wins with BPF: Getting Started
Performance Wins with BPF: Getting StartedBrendan Gregg
 
YOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at NetflixYOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at NetflixBrendan Gregg
 
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Flink Forward
 
Using eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumUsing eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumScyllaDB
 
DevConf 2014 Kernel Networking Walkthrough
DevConf 2014   Kernel Networking WalkthroughDevConf 2014   Kernel Networking Walkthrough
DevConf 2014 Kernel Networking WalkthroughThomas Graf
 
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)Red Hat Developers
 
Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)Brendan Gregg
 
netfilter and iptables
netfilter and iptablesnetfilter and iptables
netfilter and iptablesKernel TLV
 
Introduction to Apache Spark
Introduction to Apache SparkIntroduction to Apache Spark
Introduction to Apache SparkSamy Dindane
 
DoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDKDoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDKMarian Marinov
 
Linux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance ShowdownLinux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance ShowdownScyllaDB
 
Introduction to Kafka Streams
Introduction to Kafka StreamsIntroduction to Kafka Streams
Introduction to Kafka StreamsGuozhang Wang
 

La actualidad más candente (20)

BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)
 
Apache Spark At Scale in the Cloud
Apache Spark At Scale in the CloudApache Spark At Scale in the Cloud
Apache Spark At Scale in the Cloud
 
BPF: Tracing and more
BPF: Tracing and moreBPF: Tracing and more
BPF: Tracing and more
 
Cassandra 101
Cassandra 101Cassandra 101
Cassandra 101
 
A Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQLA Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQL
 
Introduction to DPDK
Introduction to DPDKIntroduction to DPDK
Introduction to DPDK
 
Performance Wins with BPF: Getting Started
Performance Wins with BPF: Getting StartedPerformance Wins with BPF: Getting Started
Performance Wins with BPF: Getting Started
 
YOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at NetflixYOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at Netflix
 
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
 
Using eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumUsing eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in Cilium
 
Fig 9-02
Fig 9-02Fig 9-02
Fig 9-02
 
DevConf 2014 Kernel Networking Walkthrough
DevConf 2014   Kernel Networking WalkthroughDevConf 2014   Kernel Networking Walkthrough
DevConf 2014 Kernel Networking Walkthrough
 
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
 
Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)
 
netfilter and iptables
netfilter and iptablesnetfilter and iptables
netfilter and iptables
 
Introduction to Apache Spark
Introduction to Apache SparkIntroduction to Apache Spark
Introduction to Apache Spark
 
DoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDKDoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDK
 
Linux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance ShowdownLinux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance Showdown
 
Introduction to Kafka Streams
Introduction to Kafka StreamsIntroduction to Kafka Streams
Introduction to Kafka Streams
 
Kafka 101
Kafka 101Kafka 101
Kafka 101
 

Destacado

Why Zsh is Cooler than Your Shell
Why Zsh is Cooler than Your ShellWhy Zsh is Cooler than Your Shell
Why Zsh is Cooler than Your Shelljaguardesignstudio
 
Vim your Python, Python your Vim
Vim your Python, Python your VimVim your Python, Python your Vim
Vim your Python, Python your VimMiroslav Šedivý
 
Zsh shell-for-humans
Zsh shell-for-humansZsh shell-for-humans
Zsh shell-for-humansJuan De Bravo
 

Destacado (6)

Why Zsh is Cooler than Your Shell
Why Zsh is Cooler than Your ShellWhy Zsh is Cooler than Your Shell
Why Zsh is Cooler than Your Shell
 
Vim your Python, Python your Vim
Vim your Python, Python your VimVim your Python, Python your Vim
Vim your Python, Python your Vim
 
Zsh shell-for-humans
Zsh shell-for-humansZsh shell-for-humans
Zsh shell-for-humans
 
Vim kindergarten
Vim kindergartenVim kindergarten
Vim kindergarten
 
Vim Rocks!
Vim Rocks!Vim Rocks!
Vim Rocks!
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 

Similar a Why zsh is Cooler than Your Shell

Linux: Beyond ls and cd
Linux: Beyond ls and cdLinux: Beyond ls and cd
Linux: Beyond ls and cdjacko91
 
basic shell scripting syntex
basic shell scripting syntexbasic shell scripting syntex
basic shell scripting syntexKsd Che
 
101 3.2.1 how-to colors and prompts in bash
101 3.2.1 how-to colors and prompts in bash101 3.2.1 how-to colors and prompts in bash
101 3.2.1 how-to colors and prompts in bashAcácio Oliveira
 
3.1.b how to - colors and prompts in bash
3.1.b how to - colors and prompts in bash3.1.b how to - colors and prompts in bash
3.1.b how to - colors and prompts in bashAcácio Oliveira
 
Bash shell programming in linux
Bash shell programming in linuxBash shell programming in linux
Bash shell programming in linuxNorberto Angulo
 
Unix Shell Tricks for Rails Developers
Unix Shell Tricks for Rails DevelopersUnix Shell Tricks for Rails Developers
Unix Shell Tricks for Rails DevelopersMatthew Swain
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboyKenneth Geisshirt
 
Linux history & features
Linux history & featuresLinux history & features
Linux history & featuresRohit Kumar
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linuxkishore1986
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands101 3.1 gnu and unix commands
101 3.1 gnu and unix commandsAcácio Oliveira
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08Tushar Jain
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentationnishantsri
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linuxrowiebornia
 
Introduction-to-Linux.pptx
Introduction-to-Linux.pptxIntroduction-to-Linux.pptx
Introduction-to-Linux.pptxDavidMaina47
 

Similar a Why zsh is Cooler than Your Shell (20)

Linux: Beyond ls and cd
Linux: Beyond ls and cdLinux: Beyond ls and cd
Linux: Beyond ls and cd
 
basic shell scripting syntex
basic shell scripting syntexbasic shell scripting syntex
basic shell scripting syntex
 
101 3.2.1 how-to colors and prompts in bash
101 3.2.1 how-to colors and prompts in bash101 3.2.1 how-to colors and prompts in bash
101 3.2.1 how-to colors and prompts in bash
 
3.1.b how to - colors and prompts in bash
3.1.b how to - colors and prompts in bash3.1.b how to - colors and prompts in bash
3.1.b how to - colors and prompts in bash
 
Bash shell programming in linux
Bash shell programming in linuxBash shell programming in linux
Bash shell programming in linux
 
Dev day linux redu
Dev day linux reduDev day linux redu
Dev day linux redu
 
Unix Shell Tricks for Rails Developers
Unix Shell Tricks for Rails DevelopersUnix Shell Tricks for Rails Developers
Unix Shell Tricks for Rails Developers
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Linux history & features
Linux history & featuresLinux history & features
Linux history & features
 
tools
toolstools
tools
 
tools
toolstools
tools
 
Linux Basics
Linux BasicsLinux Basics
Linux Basics
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linux
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands101 3.1 gnu and unix commands
101 3.1 gnu and unix commands
 
Suman bhatt
Suman bhattSuman bhatt
Suman bhatt
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
Introduction-to-Linux.pptx
Introduction-to-Linux.pptxIntroduction-to-Linux.pptx
Introduction-to-Linux.pptx
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linux
 
Introduction-to-Linux.pptx
Introduction-to-Linux.pptxIntroduction-to-Linux.pptx
Introduction-to-Linux.pptx
 

Why zsh is Cooler than Your Shell