How to Customize Mac Terminal

The more you use Mac’s Terminal application, you will begin to learn little tricks that save time and make things easier while using it. Customizing Terminal can be one thing that can really help you out.

Not only can it make things easier to read and more comfortable to use but customizing color schemes, fonts, and other things can make it more exciting to use your newfound tool or your old reliable tool if you are a longtime user.

You can customize Terminal using pre-existing Terminal profiles, or you can even create your own.

My name is Eric, and I am no stranger to using command line tools like Terminal. When you use them regularly, it is nice to be able to customize the settings, not only to make them easier to use but to put your own touch on them. 

I have done this many times, and I can show you how. So, if you want to make your Terminal sessions more efficient, easier, and maybe just a little more interesting, keep reading below.

Preset Profiles

If you’re tired of that plain old black and white look that is Terminal’s default theme or profile, you can quickly change it up. The Terminal application provides several preset profiles that you can change to, and in a matter of seconds, you can have a whole new look.

Just follow the steps below to try them out.

Step 1: Open the Terminal Application

You can start up the Terminal app using your preferred method.

Step 2: Open Terminal Settings

From the Terminal menu, click on Terminal and then Settings.

Step 3: Click on the Profiles tab.

Step 4: Select the profile you would like to use.

Double-click on a profile you would like to use, and a Terminal window will start up with that particular profile.

Create Your Own Profile

If, after going through Terminal’s preset profiles, you can’t find anything that fits all of your wants, you can take one that is close to what you are looking for and modify it to fit your desire. 

If you want to start from scratch, just start with the Basic default and make all the modifications you want until you are satisfied.

You also don’t have to feel like you must stick with just one theme. You can create one, save it, create others, and switch between them whenever you like. Create your own profiles using the following steps.

Step 1: Go to Terminal profiles

Use the same steps 1 – 3 as above to get to Terminal’s profile settings.

Step 2: Select a profile

Click on a profile close to what you are looking for; if you want, you can just start with the Basic default profile.

If you want to start from scratch (the basic profile), click on the + symbol in the lower-left corner of the window.

Suppose you would like to use an existing profile and modify it. Select the profile and then click on the dropdown menu at the bottom of the profiles. Then select Duplicate Profile.

Enter a new name for the profile.

Now you have a new profile that you can modify to suit your own preferences.

Step 3: Adjust Text settings

You can adjust any settings you would like to change. Here you can adjust the background color, background image, Font type, size, color, and other text settings.

You can also click on the other tabs to change some of the settings that will affect the behavior of the Terminal window. If you are unsure of any settings, you can always click on the question mark in the lower right corner of the window for a description of the settings.

You can experiment with any or all of the settings. They will be saved as you change them. Whenever you want to test your settings, double-click on your new profile, which will open a Terminal session with your profile and its settings.

Setting Your Default Profile

Once you have decided upon a specific profile or created one that you like, you may want to set it as the default profile so that it is used whenever you start a Terminal session. Follow the steps below to set a profile as your default.

Step 1: Click on the General Tab

If you still have Terminal settings open, click on the General tab to get to the default settings.

Step 2: Select the Default profile

Select the profile that you wish to make your default.

Step 3: Close all Terminal sessions and settings windows

For the default setting to take effect, you must close all open terminal sessions and settings windows.

Step 4: Start Terminal

Start Terminal again, and it should use your new default profile.

Changes to Your Shell Profile

We have seen how changes made at the Terminal settings level can make a difference in how your command line sessions look, but you can also make changes directly from the command line that will change how things look with the input and output of your window.

You can change things such as the command prompt characters and their color. The color of the text output on the command line can be changed, and you can even set up specific commands to provide output that is easier to read and interpret.

These settings are in the .zshrc (for Z shell) file, located in your home directory. Many settings can be placed there, affecting your command prompt, colors, and other input/output settings.

There are too many to list here, but below, we will go over just a few that can be used to quickly enhance your command line experience in Terminal.

Change the Command Prompt

It’s nice to have a command prompt that provides essential information, such as who you are logged in as, your computer name, and even your current directory. This is helpful information, especially when working with multiple windows on multiple systems.

Since the latest macOS Terminal application defaults to Z shell, I will be using Z shell commands for my examples. Other shell types, such as bash, will have the same, if not very similar, commands.

The following command will set your command prompt to show as username@hostname:cwd%, and it will also add some color to it.

PROMPT=’%K{blue}%n@%m%k %B%F{cyan}%(4~|…|)%3~%F{white} %# %b%f%k’

The parameters used in the PROMT setting are shown below.

%K – background color of the text

%n – username

@ – just puts the @ character in the prompt

%m – machine name

%k – end of background color specified by %K

%B – bold

%F – Foreground color

%(4~|…|)%3~ – This is an interactive parameter that shows the path relative to your home directory, but it limits the length, so the prompt does not become too long

%# – Shows a # sign if logged in as a root user

%b – ends bold font

%f – ends the foreground color

%k – ends the background color

You can use many parameters for your prompt and even set up an interactive prompt that changes depending on the results of commands. Z shell also has a right prompt which will put things such as the time on the right side of the screen.

You can look at this reference page to learn more about the settings and parameters for your command prompt.

Create an Alias for a Command

You can use an alias command like the one below, which will replace the standard ls command. It adds the -G, -F, and -h parameters. The -G colorizes the output, and the -F adds a / to the end of all the directory names so that you can easily identify them as a directory.

The -h parameter changes the output so that the file sizes are human-readable, which makes them a little easier to read.

alias ls=’ls -GFh’

Add Them to your .zshrc File

The settings above are just a couple of examples of things that can be added to your shell profile that can customize your Terminal experience. There are many more things you can do, but next, I will show you the steps of how to add the ones we have looked at to your shell profile.

Step 1: Open the Terminal application.

Start up the Terminal app using your preferred method.

Step 2: Open the .zshrc file.

Here we will open the file using the nano editor, but you can use any editor you choose. Use the command below to open it using nano.

nano .zshrc

Step 3: Enter the setting into .zshrc.

You can type them in or copy them from here and paste them into the file.

PROMPT=’%K{blue}%n@%m%k %B%F{cyan}%(4~|…|)%3~%F{white} %# %b%f%k’

alias ls=’ls -GFh’

Step 4: Save and close the file.

Once you have pasted the command into the editor, you will then need to save and exit nano. Hit CONTROL+O to save the file and then CONTROL+X to exit.

Step 5: Run the .zshrc file

After saving the .zshrc file, you can run it to see the changes take effect. Just type the following command.

. ./zshrc

You should now see the new prompt, and if you run the ls command, you will see the enhanced output created by the alias command. The .zshrc file will run anytime you open up a terminal session, so there is no need to run the new command every time. Just start up Terminal, and you will be good to go.

FAQs

Once you start looking at ways to customize your Mac Terminal you may have many questions. Below are a few that come up quite often.

Why Should I Customize my Mac Terminal?

Terminal customization can help you to be more efficient and comfortable using the command line. It can help you to to see and read things easier. Using different colors for different terminal sessions can also help you keep track of what you are doing in each of them.

Besides the above benefits, it can just be plain fun to see what you can do with different profiles and helps to keep your work in Mac Terminal more interesting.

How do I set the right prompt?

The right prompt in Z shell is set with the RPROMT variable. So you can set it in your .zshrc file or even set it right from the command line using a command such as the one below.

RPROMPT=’%*’

This setting will show the time on the screen’s right side for each run command.

Can I use the PS1 variable to set my prompt in Z shell?

The PS1 variable was the variable used to set your prompt in older shells like bash, K shell, and others, but it does still work in Z shell. It is interchangeable with the PROMT variable.

Conclusion

As you can see, there are many ways to customize your Terminal application on your Mac. There are so many that we can’t list them all here, but using the preset profiles Mac provides is a great start, and it’s pretty easy to modify those profiles to fit your needs.

Modifying the settings in your Terminal shell is another way that you can customize your Terminal experience. Adding settings to your .zshrc file can provide some very nice enhancements to your command line input and output.

I hope the information provided can get you started in customizing your Terminal application. As usual, let me know if you have any questions or give me feedback on your customizations have gone. I would love to hear from you.

Leave a Reply

Your email address will not be published.