How to Customize Your Mac’s Terminal for Better Productivity

If you spend any time in Terminal on your Mac, it’s worth customizing the look and feel of the application. Here are some of the most interesting ways you can customize your Mac’s Terminal windows.

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.

customize-terminal-macos-terminal-preferences-menu

In the Preferences window select the “Profiles” tab. These options will adjust the appearance of new Terminal windows.

customize-terminal-macos-terminal-preferences-window

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.

customize-terminal-macos-terminal-create-new-profile

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.

customize-terminal-macos-terminal-set-profile-default

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.

customize-terminal-macos-terminal-new-shell-with-profile

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.

customize-terminal-macos-preferences-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.

customize-terminal-macos-start-up-command

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.

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.

customize-terminal-macos-colorize-shell-prompt-1

Open your “.bash_profile” in nano with the command below:

customize-terminal-macos-open-bash-profile

customize-terminal-macos-edit-bash-profile

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.

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.”

customize-terminal-macos-change-text-color-profile

To colorize text temporarily, use something like the command below:

This will have the following result.

customize-terminal-macos-change-text-color-ansi

  • " opens the printf string
  • \e escapes the non-printing characters
  • [31m is the color code for red text
  • Hello World is our string literal
  • \e[0m clears formatting so the new text does not appear colorized
  • \n prints 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 printf.

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.

By default, Terminal will show the present working directory, active process, and viewport size in your Terminal window’s title bar.

customize-terminal-macos-window-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.

customize-terminal-macos-change-terminal-window-title

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.

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.

Sponsored Stories