Aliases (PowerShell users, skip this section)
Since we saw that rm
is a wrecking ball, we should temper it using the -i
flag. For safety, we would like rm
to always ask us about deletion. We can instruct bash
or zsh
to do this for us by creating an alias.
alias rm="rm -i"
After executing this, any time we use rm
, our shell will instead execute rm -i
, thereby keeping us out of trouble.
Another useful alias, often implemented by default, is to make ls
list things more prettily.
For macOS:
alias ls="ls -FG"
For Linux:
alias ls="ls -F --color"
The -F
flag makes ls
put a slash at the end of directories. This helps us tell the difference between files and directories. The -G
or --color
flag enables coloring of the output, also useful for differentiating file types.
Furthermore, if you decide to use rsync
, you may want to alias rsync -avzP
to rsync
:
alias rsync="rsync -avzP"
Aliases will usually be forgotten when you close the current terminal. To make them persistent, add the command to ~/.bashrc
(on most Linux or old macOS) or ~/.zshrc
(on macOS). If these files do not exist, you can create them.
Copyright note: In addition to the copyright shown below, this recitation was developed based on materials from Axel Müller.