Why is Mac Terminal Showing % Instead of $

Longtime users of Mac’s Terminal application or those using a Mac with an older macOS have probably gotten familiar with seeing the $ prompt when using the command line interface. Now after upgrading your macOS, you are seeing a % prompt. Why?

The answer is quite simple. Newer Macs and macOS have changed the shell interface in Terminal from bash to Z shell or zsh for short. The default command prompt for zsh is the % character, so this is most likely what you will see when using your command line interface.

My name is Eric, and I have been a computer enthusiast and software engineer for many years. We often find comfort in how our systems appear and function, so a change such as a command prompt that we are used to can often cause us concern until we find out why.

If you want to hear more about why you may be seeing this change from the $ prompt to the % prompt, keep reading below, and I will let you know a little more about why this may have happened. I will also show you how to change it if you wish to do so.

Mac Terminal’s Default Prompt

I have touched on the reason briefly above, and if you are seeing a % for your prompt in Terminal and were previously seeing a $, then most likely you upgraded your macOS to a version that now uses zsh for your command shell. 

You can tell by looking at the top of the Terminal application’s window, as shown above. You can also see what shell you are in by typing the following command.

echo $SHELL

Starting in 2019, macOS Catalina began using zsh as the default command shell for Terminal. If you had an older macOS and recently upgraded, this is the most likely reason for the change.

Z shell is a newer, more robust command shell that allows you to use almost all of the same commands you are familiar with in the bash command shell. Still, it has many new features and capabilities, so Apple sent out all new macOS upgrades with it.

Does it Make a Difference?

The shell you are using in Mac Terminal can make a slight difference since newer shells often have new features and capabilities, but the actual prompt symbol ($ or %) does not make any difference in how the shell functions. It is merely cosmetic.

You can have a $ symbol for a prompt and be running zsh, or you can have a % symbol and be running bash. You can do this by setting the properties of your prompt and I will show you how to do that in the next section.

By default, the command prompt symbol may indicate what shell you are using, but since users can change it, it does not mean that it is always accurate, so you can’t rely on this being the case. 

If you want to tell which shell you are using, use the echo $SHELL command as shown above, or you can also just type something that you know is not a real shell command, and the error message will show you what shell you are using. See the example below.

Ways to Get Your $ Prompt Back

If you want your $ prompt back for whatever reason, there are several ways to bring it back. The first way is to change your prompt settings. This will use a $ prompt instead of the % prompt even though you are still using zsh. 

The other way is to change your shell back to bash. I recommend using the first method of just changing your prompt so that you can continue taking advantage of the new features provided by zsh, but if you are ok with using bash then the other option can work for you also. 

Update your PROMPT Settings

Z shell uses the PROMPT variable to set your command line prompt. So, this is relatively easy to change if you would like to do so. If you just want your prompt to be a single $ character, all you need to do is set the PROMPT variable to be equal to $, as shown below.

export PROMPT=$

There are many variations of how you can set the prompt variable, and you can explore how to do this if you would like.

If you want to have this setting permanently so that you don’t have to run the export command above every time you log in, you can put this setting in your .zshrc file, and it will run every time you start Terminal.

Use the steps below to do this.

Step 1: Open Terminal

Use your preferred method to open the Terminal application.

Step 2: Make sure you are in your home directory.

You need to make sure you are in your home directory. You can do so by simply typing the cd command as shown below.

cd 

Step 3: Open the .zshrc file.

Open the .zshrc file using your favorite command line editor. For our example below, I will use the nano editor.

nano .zshrc

Step 4: Add the export line to the file.

Type or copy and paste the following line into the file.

export PROMPT=$

This file may be empty, but if not, it’s okay, and you may see other lines of data in there. If so, just enter this line below the other entries.

Step 5: Save the file.

Hit CONTROL+X to save and exit.

Every time you start up Terminal, you will have a single $ for your prompt. If you have other changes to your prompt you would like to add, you can put those in the .zshrc file as well. To see the changes instantly, you can run the .zshrc file as shown below.

. ./.zshrc

Use bash instead of zsh

Using an older shell is a roundabout way to do this, but if you prefer to use bash, you still can. You can easily get into the bash shell by just typing bash.

bash 

You can also set bash to be your default shell in Terminal. This will mean that bash will be your command shell anytime you start the Terminal application. Follow the steps below if you wish to do this.

Step 1: Open Terminal

Use your preferred method to open the Terminal application.

Step 2: Go to Terminal settings.

Click on the Terminal settings from the Menu at the top of the screen.

Step 3: Change the default shell.

In the section labeled Shells open with, click on the radio button that says Command (complete path):, then type in /bin/bash into the text field to tell it that you wish to use bash.

Step 4: Exit and restart the Terminal application.

Get out of the settings page and then exit the Terminal application. When the Terminal restarts, you will be in bash shell.

FAQs

Below are a few questions often asked when discussing Mac Terminal’s prompt and the command shell.

What if I see a # symbol?

If you see the # symbol as your prompt, it often means that you are logged in as or have used the sudo command to change to the root user account. This should be a warning to be careful since you will have the ability to do anything on the system.

What other symbols can I use for my prompt?

You can use any characters you want for your command prompt. Standards are often used so that a user can tell by just looking to see what shell they are using and who they are logged in as, but you can set your command prompt to look any way that you design it.

What does it mean to have an interactive prompt?

An interactive prompt changes depending on who you are logged in as and possibly based upon the results of a command. The # prompt discussed in the first question is an example, but in zsh, you can set it up to change based on many other conditions.

Conclusion

When Mac Terminal is showing a % instead of a $ as your command prompt, there is a high chance that your Mac Terminal is now using Z shell as its default command line shell. 

There’s no need to worry since Z shell is an upgrade to bash, and most of your commands will still work as they did before. This is only a cosmetic change; you can change it if you want to by setting your PROMPT variable with your own parameters.

As usual, let me know if you have any questions or comments. I would love to hear from you!

Leave a Reply

Your email address will not be published. Required fields are marked *