Learning Shell Scripting with Zsh

Learning Shell Scripting with Zsh
eBook: $17.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $47.98    Print cover: $29.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • A step-by-step guide that will show you how to use zsh and its repertoire of powerful features to improve the efficiency of your daily tasks
  • Learn how to configure and use zsh
  • Discover some advanced features of zsh such as process and parameter substitution, running on restricted functionality mode, and emulating other shells

Book Details

Language : English
Paperback : 132 pages [ 235mm x 191mm ]
Release Date : January 2014
ISBN : 1783282932
ISBN 13 : 9781783282937
Author(s) : Gastón Festari
Topics and Technologies : All Books, Application Development, Open Source

Table of Contents

Chapter 1: Getting Started
Chapter 2: Alias and History
Chapter 3: Advanced Editing
Chapter 4: Globbing
Chapter 5: Completion
Chapter 6: Tips and Tricks
  • Chapter 1: Getting Started
    • Installing zsh
      • Installing on Linux
      • Installing on OS X
      • Compiling from source
    • First run
      • Making zsh your login shell
      • Shell options
      • The startup files
    • The shell prompt
      • The prompt command
      • Customizing the prompt
      • Using escape sequences
      • Conditional expressions
      • Putting it all together
    • Summary
  • Chapter 2: Alias and History
    • Working with aliases
      • Quoting characters
      • Single and double quoting aliases
      • Global aliases
      • Hashes
      • Putting it all together
    • Expansion
      • Parameter expansion
      • Command substitution
      • Arithmetic expansion
      • Brace expansion
    • Working with history
      • History expansion
      • History substitution
      • More useful options
    • Summary
  • Chapter 3: Advanced Editing
    • Zsh line editor
      • Getting to know ZLE
      • Working with keymaps
      • Basic editing
        • Going back and forth with words
        • Yanking and transposing text
      • Revisiting history
    • Advanced editing
      • ZLE-related options
      • Defining your own keymaps
    • Don't call them widgets
      • Defining your own widgets
      • Your first function
    • Working with regions
      • Multiline editing
      • Putting it all together
    • Summary
  • Chapter 4: Globbing
    • Quoting your strings
      • Double quotes
    • Getting started with Globbing
      • Globbing with the stars
      • Questions for any single character
      • Brackets for a sequence of characters
      • Using safer ranges on your scripts
        • Avoiding characters
      • Handling mismatches
    • Extended Globbing
      • Special patterns
        • Recursive searching
        • Alternate patterns
        • Numeric ranges
        • Revisiting the caret operator
        • The tilde operator
      • Glob qualifiers
        • Timestamp qualifiers
        • File size qualifiers
    • The zmv function
    • Summary
  • Chapter 5: Completion
    • Getting started with completion
      • Getting assertive with zstyle
    • Command correction
      • Completers
      • Ignoring matches
    • Function definitions
      • The path of the function
    • Summary
  • Chapter 6: Tips and Tricks
    • Main resources
    • Helping tips
      • Directory substitution
      • Magic space
      • Random numbers
      • zcalc
      • Change and list directory contents
      • Finding your path through commands
    • Other projects
      • zsh-lovers
      • zsh-users
      • oh-my-zsh
      • Prezto
      • Explain Shell
      • Your dotfiles
    • Summary

Gastón Festari

Gastón Festari is a scripting language enthusiast with over five years of experience and a firm believer in free, open source software. Currently working as a developer for Globant, he likes to spread the word about zsh at different meetups and events when away from the keyboard.

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


- 3 submitted: last submission 17 Jun 2014

Errata type: Technical | Page no. 87

The last line on the page is
This will provide the files modified between five and two hours.

It should be
This will provide the files modified between five days and two hours. 

Errata type: Typo | Page no. 11

In the fourth line of the first paragraph of information box, there is sentence saying
...it is case-insensitive and ignores underscores and ignores underscores.

It should be
it is case-insensitive and ignores underscores.

Note that "and ignores underscores" is repeated by mistake


Errata type: Typo | Page no. 12

The third line of the second paragraph of the page is
On the other hand, Apply interactive shells get called to execute a script...

It should be
On the other hand, non-interactive shells get called to execute a script...

Errata type: Code | Page no. 11/17

You should either use 
    autoload -U promptinit 
And then, either call 
    % promptinit # missing on page 17
    % prompt -p
Or do it all in one swoop (recommended) as follows:
    # this sets up and initializes the prompt
    # put this on your ~/.zshrc file
    autoload -U promptinit && promptinit
Notice the extra (&& promptinit)
Then, as suggested, call the following from a terminal emulator: 
    % prompt -p
And you'll be all set.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Learning Shell Scripting with Zsh +    Learning Joomla! 1.5 Extension Development: Creating Modules, Components, and Plugins with PHP =
50% Off
the second eBook
Price for both: £14.25

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Set up and configure the advanced aspects of zsh such as process and parameter substitution, running on restricted functionality mode, and emulating other shells, for example, ksh and Bourne
  • Customize the shell prompt to display the information you need
  • Work with the line-editor module to type less and do more
  • Use filename generation, also known as globbing, to work with files and folders
  • Discover programmable completion and never mistype a command or its options again
  • Tame the shell history and use it simultaneously on multiple shells with just a few keystrokes
  • Expand on zsh’s built-in modules and functionality by creating your own functions

In Detail

Zsh has become incredibly popular in recent times and reasonably so; the shell boasts some really great features such as command completion, filename generation, and history sharing among instances of the shell. Learning to use them to your advantage will prove to be really valuable and will save you from lots of tedious and overly-complex tasks.

This hands-on guide will show you how to configure and use zsh for work and daily tasks. It provides a clear introduction to the more powerful features of the shell such as globbing and completion. This book will help you take advantage of the real power behind the UNIX shell on both desktops and servers through real-world examples.

This book will help you understand the features of zsh and make it one of the most valuable assets in your toolbox. It will teach you how to use the shell history to look up and edit previously typed entries and take advantage of the line-editor module to speed up your typing and editing of commands. You will be able to create your own completion functions and ensure you never mistype a command or have to look at the manpages again.

You will learn how to define your own aliases and learn about filename generation so you can do more by typing even less. You will also discover the essentials of zsh and go deeper with its more advanced features. When you are done with this book, your time with the command line will be much more enjoyable and productive.


A step-by-step tutorial that will teach you, through real-world examples, how to configure and use zsh and its various features.

Who this book is for

If you are a system administrator, developer, or computer professional involved with UNIX who are looking to improve on their daily tasks involving the UNIX shell, "Learning Shell Scripting with zsh" will be great for you. It’s assumed that you have some familiarity with an UNIX command-line interface and feel comfortable with editors such as Emacs or vi.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software