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)

Working with aliases


An alias is an alternative way of saying the same thing. Think of it as a nickname for your commands. Though, unlike the embarrassing nicknames that you might get after a party, the alias mechanism provided by your shell is a handy shortcut to a series of commands and options under a friendlier name. The whole point of an alias is to do more and, preferably, type less.

I bet I got your attention with that last "type less" part. Allow me to explain:

The ls command lists a directory's contents. A quick look at its manpage (man ls) tells us that there are quite a few options there:

ls -a # lists all files, even those hidden that start with a dot
ls -l # shows more information for each file, like size and permissions

Using aliases we can go ahead and do something like the following:

% alias la='ls -a'

Note

No spaces are allowed around the equals (=) sign. If the right-hand side of the assignment (that is, the part that comes after the equals) contains spaces or tabs, then make...