Why Zsh is Cooler than Your Shell

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
Why Zsh is Cooler than Your Shell
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
1 of 60

Recommended

Network Programming: Data Plane Development Kit (DPDK) by
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Andriy Berestovskyy
2.3K views65 slides
Linux Performance Analysis and Tools by
Linux Performance Analysis and ToolsLinux Performance Analysis and Tools
Linux Performance Analysis and ToolsBrendan Gregg
531.1K views115 slides
DPDK KNI interface by
DPDK KNI interfaceDPDK KNI interface
DPDK KNI interfaceDenys Haryachyy
26.1K views10 slides
Understanding DPDK by
Understanding DPDKUnderstanding DPDK
Understanding DPDKDenys Haryachyy
102.4K views42 slides
Interpreter, Compiler, JIT from scratch by
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchNational Cheng Kung University
11.9K views62 slides
OVS Hardware Offload with TC Flower by
OVS Hardware Offload with TC FlowerOVS Hardware Offload with TC Flower
OVS Hardware Offload with TC FlowerNetronome
3.6K views28 slides

More Related Content

What's hot

The Internals of "Hello World" Program by
The Internals of "Hello World" ProgramThe Internals of "Hello World" Program
The Internals of "Hello World" ProgramNational Cheng Kung University
15.3K views74 slides
Kernel Proc Connector and Containers by
Kernel Proc Connector and ContainersKernel Proc Connector and Containers
Kernel Proc Connector and ContainersKernel TLV
2.5K views18 slides
Vulkan 1.0 Quick Reference by
Vulkan 1.0 Quick ReferenceVulkan 1.0 Quick Reference
Vulkan 1.0 Quick ReferenceThe Khronos Group Inc.
8.6K views13 slides
X / DRM (Direct Rendering Manager) Architectural Overview by
X / DRM (Direct Rendering Manager) Architectural OverviewX / DRM (Direct Rendering Manager) Architectural Overview
X / DRM (Direct Rendering Manager) Architectural OverviewMoriyoshi Koizumi
8.7K views16 slides
Performance Wins with BPF: Getting Started by
Performance Wins with BPF: Getting StartedPerformance Wins with BPF: Getting Started
Performance Wins with BPF: Getting StartedBrendan Gregg
2K views24 slides
DPDK: Multi Architecture High Performance Packet Processing by
DPDK: Multi Architecture High Performance Packet ProcessingDPDK: Multi Architecture High Performance Packet Processing
DPDK: Multi Architecture High Performance Packet ProcessingMichelle Holley
9.1K views52 slides

What's hot(20)

Kernel Proc Connector and Containers by Kernel TLV
Kernel Proc Connector and ContainersKernel Proc Connector and Containers
Kernel Proc Connector and Containers
Kernel TLV2.5K views
X / DRM (Direct Rendering Manager) Architectural Overview by Moriyoshi Koizumi
X / DRM (Direct Rendering Manager) Architectural OverviewX / DRM (Direct Rendering Manager) Architectural Overview
X / DRM (Direct Rendering Manager) Architectural Overview
Moriyoshi Koizumi8.7K views
Performance Wins with BPF: Getting Started by Brendan Gregg
Performance Wins with BPF: Getting StartedPerformance Wins with BPF: Getting Started
Performance Wins with BPF: Getting Started
Brendan Gregg2K views
DPDK: Multi Architecture High Performance Packet Processing by Michelle Holley
DPDK: Multi Architecture High Performance Packet ProcessingDPDK: Multi Architecture High Performance Packet Processing
DPDK: Multi Architecture High Performance Packet Processing
Michelle Holley9.1K views
Note - (EDK2) Acpi Tables Compile and Install by boyw165
Note - (EDK2) Acpi Tables Compile and InstallNote - (EDK2) Acpi Tables Compile and Install
Note - (EDK2) Acpi Tables Compile and Install
boyw1652.1K views
Behm Shah Pagerank by gothicane
Behm Shah PagerankBehm Shah Pagerank
Behm Shah Pagerank
gothicane3K views
Linux 4.x Tracing: Performance Analysis with bcc/BPF by Brendan Gregg
Linux 4.x Tracing: Performance Analysis with bcc/BPFLinux 4.x Tracing: Performance Analysis with bcc/BPF
Linux 4.x Tracing: Performance Analysis with bcc/BPF
Brendan Gregg10.7K views
Ninja Build: Simple Guide for Beginners by Chang W. Doh
Ninja Build: Simple Guide for BeginnersNinja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for Beginners
Chang W. Doh43.8K views
Linux BPF Superpowers by Brendan Gregg
Linux BPF SuperpowersLinux BPF Superpowers
Linux BPF Superpowers
Brendan Gregg422.8K views
CETH for XDP [Linux Meetup Santa Clara | July 2016] by IO Visor Project
CETH for XDP [Linux Meetup Santa Clara | July 2016] CETH for XDP [Linux Meetup Santa Clara | July 2016]
CETH for XDP [Linux Meetup Santa Clara | July 2016]
IO Visor Project6K views
Function Level Analysis of Linux NVMe Driver by 인구 강
Function Level Analysis of Linux NVMe DriverFunction Level Analysis of Linux NVMe Driver
Function Level Analysis of Linux NVMe Driver
인구 강1.6K views
LinuxCon 2015 Linux Kernel Networking Walkthrough by Thomas Graf
LinuxCon 2015 Linux Kernel Networking WalkthroughLinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking Walkthrough
Thomas Graf26.2K views

Viewers also liked

Why zsh is Cooler than Your Shell by
Why zsh is Cooler than Your ShellWhy zsh is Cooler than Your Shell
Why zsh is Cooler than Your Shellbrendon_jag
44.1K views60 slides
Kibanaでログを可視化してみた by
Kibanaでログを可視化してみたKibanaでログを可視化してみた
Kibanaでログを可視化してみたDaigou Harada
2.7K views15 slides
Vim your Python, Python your Vim by
Vim your Python, Python your VimVim your Python, Python your Vim
Vim your Python, Python your VimMiroslav Šedivý
1.7K views46 slides
Vim kindergarten by
Vim kindergartenVim kindergarten
Vim kindergartenYuta Totsuka
1.1K views18 slides
Vim Rocks! by
Vim Rocks!Vim Rocks!
Vim Rocks!Kent Chen
9.7K views76 slides

Viewers also liked(15)

Why zsh is Cooler than Your Shell by brendon_jag
Why zsh is Cooler than Your ShellWhy zsh is Cooler than Your Shell
Why zsh is Cooler than Your Shell
brendon_jag44.1K views
Kibanaでログを可視化してみた by Daigou Harada
Kibanaでログを可視化してみたKibanaでログを可視化してみた
Kibanaでログを可視化してみた
Daigou Harada2.7K views
Vim Rocks! by Kent Chen
Vim Rocks!Vim Rocks!
Vim Rocks!
Kent Chen9.7K views
Vim Hacks by Lin Yo-An
Vim HacksVim Hacks
Vim Hacks
Lin Yo-An86.6K views
CpawCTF 勉強会 Network by Takaaki Hoyo
CpawCTF 勉強会 NetworkCpawCTF 勉強会 Network
CpawCTF 勉強会 Network
Takaaki Hoyo19.7K views
Railsチュートリアルの歩き方 (第4版) by Yohei Yasukawa
Railsチュートリアルの歩き方 (第4版)Railsチュートリアルの歩き方 (第4版)
Railsチュートリアルの歩き方 (第4版)
Yohei Yasukawa427.8K views
今さら聞けないカーネル法とサポートベクターマシン by Shinya Shimizu
今さら聞けないカーネル法とサポートベクターマシン今さら聞けないカーネル法とサポートベクターマシン
今さら聞けないカーネル法とサポートベクターマシン
Shinya Shimizu131.6K views
Design Sprint 概要 / デザインスプリント概要 by Takaaki Umada
Design Sprint 概要 / デザインスプリント概要Design Sprint 概要 / デザインスプリント概要
Design Sprint 概要 / デザインスプリント概要
Takaaki Umada232.8K views
SVMについて by mknh1122
SVMについてSVMについて
SVMについて
mknh1122276.7K views
Design Sprint Process / デザインスプリントの実際のプロセスについて by Takaaki Umada
Design Sprint Process / デザインスプリントの実際のプロセスについてDesign Sprint Process / デザインスプリントの実際のプロセスについて
Design Sprint Process / デザインスプリントの実際のプロセスについて
Takaaki Umada149.3K views
Tokyo.R 41 サポートベクターマシンで眼鏡っ娘分類システム構築 by Tatsuya Tojima
Tokyo.R 41 サポートベクターマシンで眼鏡っ娘分類システム構築Tokyo.R 41 サポートベクターマシンで眼鏡っ娘分類システム構築
Tokyo.R 41 サポートベクターマシンで眼鏡っ娘分類システム構築
Tatsuya Tojima248.7K views

Similar to Why Zsh is Cooler than Your Shell

Linux: Beyond ls and cd by
Linux: Beyond ls and cdLinux: Beyond ls and cd
Linux: Beyond ls and cdjacko91
580 views39 slides
101 3.2.1 how-to colors and prompts in bash by
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
184 views5 slides
3.1.b how to - colors and prompts in bash by
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
238 views5 slides
Linux history & features by
Linux history & featuresLinux history & features
Linux history & featuresRohit Kumar
4.6K views22 slides
Linux Basics by
Linux BasicsLinux Basics
Linux Basicssathish sak
56 views17 slides
Unleash your inner console cowboy by
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboyKenneth Geisshirt
802 views40 slides

Similar to Why Zsh is Cooler than Your Shell(20)

Linux: Beyond ls and cd by jacko91
Linux: Beyond ls and cdLinux: Beyond ls and cd
Linux: Beyond ls and cd
jacko91580 views
101 3.2.1 how-to colors and prompts in bash by Acácio Oliveira
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
Acácio Oliveira184 views
3.1.b how to - colors and prompts in bash by Acácio Oliveira
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
Acácio Oliveira238 views
Linux history & features by Rohit Kumar
Linux history & featuresLinux history & features
Linux history & features
Rohit Kumar4.6K views
basic shell scripting syntex by Ksd Che
basic shell scripting syntexbasic shell scripting syntex
basic shell scripting syntex
Ksd Che1.2K views
Unix Shell Tricks for Rails Developers by Matthew Swain
Unix Shell Tricks for Rails DevelopersUnix Shell Tricks for Rails Developers
Unix Shell Tricks for Rails Developers
Matthew Swain536 views
Introduction to-linux by kishore1986
Introduction to-linuxIntroduction to-linux
Introduction to-linux
kishore198642 views
Introduction to-linux by rowiebornia
Introduction to-linuxIntroduction to-linux
Introduction to-linux
rowiebornia10 views
Introduction-to-Linux.pptx by DavidMaina47
Introduction-to-Linux.pptxIntroduction-to-Linux.pptx
Introduction-to-Linux.pptx
DavidMaina470 views
Unix tutorial-08 by Tushar Jain
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
Tushar Jain720 views

Why Zsh is Cooler than Your Shell