Book Image

Learning Shell Scripting with Zsh

By : Gaston Festari
Book Image

Learning Shell Scripting with Zsh

By: Gaston Festari

Overview of this book

Table of Contents (13 chapters)

Helping tips

What follows is a list of "nice things to have" on your configuration files, aliases, and functions. Think of these as a helping hand with some of the more boring tasks that involve the command line.

Directory substitution

This is one of the cooler tricks you can pull with zsh, albeit a bit hidden from plain sight. Did you know you can use cd for switching between parallel directories without even typing the whole path? Let's work with an example.

Say you were located in the directory /zsh/completion/unix/; now, see the following command:

% cd completion doc

This command would effectively move your current working directory to /zsh/doc/unix/, provided both the directories have the same tree structure and are located on the same branch level. I know, I too can't imagine myself living without it.

Remember, you can set the AUTOCD option to enable cd just by typing the name of a directory, provided that the directory exists and is not an ambiguous match, of course.

Magic space

It's safe...