Tweaking Terminal’s Theme
Terminal has the built-in ability to theme your shell windows, but you’d never know it by looking at the default white screen.
Navigate to “Terminal -> Preferences” from Terminal’s menu bar.
In the Preferences window select the “Profiles” tab. These options will adjust the appearance of new Terminal windows.
Adjustable appearance settings include background and text color, text-rendering options, text size and typeface, cursor type, selection color, and ANSI colors. ANSI colors are used when a Terminal command displays colored output but won’t appear otherwise.
You’ll notice a number of pre-existing profiles in the menu on the left pane. You can choose one of these or click the “+” button at the bottom of the pane to create a new profile. Profiles are the containers for your settings, so you may want to create a personal profile before tweaking anything.
When ready, set your new profile as your default by clicking the “Default” button at the bottom of the profile pane. All new Terminal windows will now open in this profile.
You can also open Terminal windows in a specific profile from “Shell -> New Window,” which allows you to select the profile for the new shell.
Terminal can run specific shell commands when a shell window is open. These can be assigned on a per-profile basis, so different profiles execute different commands.
Open Terminal’s preference window from “Terminal -> Preferences,” and click on the “Shell” tab.
Under “Startup” check the box next to “Run Command,” then type the shell command you want to execute on startup. Leave “Run inside shell” checked below it.
This setting will auto-save to the associated profile and run the next time a shell is opened in that profile. To turn off the startup command, uncheck the box next to “Run command” to disable.
Colorizing Your Prompt
By editing “.bash_profile,” we can colorize the text in your Terminal prompt. For the neophyte, that’s the fixed text that appears when you open a new shell to the left of the text entry cursor.
Open your “.bash_profile” in nano with the command below:
With “.bash_profile” open, we will want to add a new line that starts with:
After the equal sign we will include our ANSI color codes. Your PS1 also needs to contain any escape sequences for variables like user name, host name, current working directory, and so on. For the prompt in the screenshots, I’ve used the colorization rules below:
That prompt includes numerical ANSI color codes as well as escape sequences for the user (
u), host (
h), and present working directory (
W). For a detailed explanation of how this gibberish works, reference our post on colorizing your shell prompt in Linux. You will also want a chart of the xterm-256-compatible ANSI color codes.
Colorize and Format Terminal Text
Typed text in Terminal can be formatted via profile settings or directly through typing shell commands.
To attach a text color to a profile, use the text color setting in “Terminal -> Preferences -> Text.”
To colorize text temporarily, use something like the command below:
This will have the following result.
"opens the printf string
eescapes the non-printing characters
[31mis the color code for red text
Hello Worldis our string literal
e[0mclears formatting so the new text does not appear colorized
nprints a new line
"closes the printf string
If you want the text to continue to appear colorized, leave off the
e[0m . To end formatting, print
e[0m to standard output with
Any of the ANSI color codes can be used here; see the above-linked guide for more details.
Typed text can be formatted beyond colorization. If you’re an insane person, you can make the text blink!
Find more eye-straining options in this complete guide to formatting shell text.
Change Window Title
By default, Terminal will show the present working directory, active process, and viewport size in your Terminal window’s title bar.
The title bar’s contents can be adjusted in the “Window” tab of Terminal’s preferences.
Open Terminal’s preference window from “Terminal -> Preferences,” and select the “Window” tab.
Adjust the settings near the top to modify the window’s title. You can see the results reflected in any currently-open shells running the profile you’re editing.
These are only the “greatest hits” of Terminal customization. There is much more you can do to customize your Terminal. Explore the Terminal Preferences menu to find more.