If you spend any time in Terminal on your Mac, it’s worth customizing the look and feel of the application. The good news is that there are lots of ways to customize your Mac’s terminal to be more productive and efficient.
In this post, we show you some of the most interesting ways you can customize your Mac’s Terminal windows.
Also read: How to Open Any Folder from the Mac Terminal
Tweaking the Terminal Theme
Terminal has the built-in ability to theme up your shell windows, although you may not notice at first glance. To do so, navigate to the Terminal’s Preferences screen.
From here, select the Profiles tab. This section will let you adjust the appearance of the Terminal window.
You’re able to change the background and text color, text-rendering options, font sizes and typefaces, the cursor type, selection color, and ANSI colors. The latter is used when a Terminal command displays a colorized output but doesn’t appear otherwise.
You’ll notice a number of profiles in the menu on the left. You can choose one of these or click the “+” icon at the bottom of the pane to create a new custom profile. Profiles are the containers for your settings, so you may want to create a personal profile before tweaking anything.
When you’re ready, set your new primary profile by clicking the Default button. All new Terminal windows will now open with this profile.
You can also open Terminal windows in a specific profile from “Shell -> New Window,” where you can also select a profile.
You can also import profiles to the Terminal, too, from the menu at the bottom of the Profiles screen.
This gives you a way to harmonize your Terminal experience with other versions of the profile in different apps. For example, your Vim editor, Terminal, and Slack app could all have the same profile and theme installed.
Login Commands
The Terminal can run specific commands when a shell window is open. You can assign these on a per-profile basis, so different profiles execute unique commands.
To do this, select the Shell tab within the Profiles preference pane.
Under Startup, check the “Run Command” box, then type the relevant command you want to execute, but leave the “Run inside shell” box checked here.
This setting will auto-save to the associated profile and run the next time you open a shell with that profile. To turn off the startup command, simply uncheck the “Run command” box.
Also read: 4 of the Best Alternatives for the macOS Terminal App
Colorizing Your Prompt
By editing the “.zshrc” file, you can colorize the Terminal prompt text. This is the fixed text that appears within a shell window.
To begin, open your “.zshrc” file in the nano editor with the following command:
nano ~/.zshrc
Within the editor, add a new line that starts with PROMPT=
. Your ANSI color codes and prompt styling will follow on. The full code we have here is:
PROMPT="%F{cyan}%n %1~ %# %f"
To break down our example, we encased the styling in %F
and %f
to note that we’ll use a color, then added a color name in curly braces {cyan}
. This can also be a number between 0 and 256.
From there, we gave some prompt styling:
- Show the user name (
%n
) - Display the current working directory path without the home directory (
%1~
) - Set to show a hash symbol if the user is a root administrator or otherwise show a percent sign (
%#
)
There’s much more you can do here, and the process is easier than using bash profiles as per previous Terminal versions.
Colorize and Format Terminal Text
You can also format typed text in the Terminal using profile settings or shell commands direct in the prompt.
To attach a text color to a profile, use the text color setting in the “Profiles -> Text” screen of the Terminal preferences.
To color text on a temporary basis, you encase text within double quotes and use the printf
command:
printf "\e[31mHello World\e[0m\n"
Let’s break this down:
\e
escapes the non-printing characters[31m
is the color code for red textHello World
is our string literal\e[0m
clears formatting so the new text does not appear colorized\n
prints a new line
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
.
You can also use the same ANSI codes from earlier and go into greater depth when it comes to your prompt formatting.
Also read: How to Change Your Mac’s Computer Name
Change the Terminal Window Title
By default, Terminal will show the present working directory, active process, and viewport size in your Terminal window’s title bar.
You can change this from the “Profile -> Window” tab of Terminal’s Preferences.
You can adjust the settings under the Title section and see the results within any open shell windows running your current profile. The same broad settings can also be found within the Tab screen in case you want to replicate your settings for multiple open tabs.
Wrapping Up
Making the Terminal your own is a great way to personalize your experience and become more efficient and productive. In fact, there’s much more you can do to customize your Mac’s Terminal, and this post showcases the greatest hits.
With a Terminal tailored to your specific requirements, you could run the whole of your computer from the Terminal or even update your Mac from the Terminal. Will you use the Terminal more if you are able to customize it? Let us know in the comments section below!
Our latest tutorials delivered straight to your inbox