Tailoring Shell Behavior

To configure all your shells to work in a particular way, edit the file .bash_profile in your home directory. This file executes each time you open bash in Terminal or log in remotely (discussed in Running a Shell Remotely). It can set variables and aliases, run programs, print your horoscope, or whatever you like.

This file is an example of a shell script: a file containing shell commands that can be executed as a unit. We’ll cover this feature in more detail in Programming with Shell Scripts.

Get Macintosh Terminal Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.