By default, your ZSH shell shows the username, hostname and current directory. But what if you want to show the full path in the Terminal?

Show full path in the ZSH prompt on macOS.

Here you learn how to replace the default prompt with one that omits user information and just shows the full path.


dave@mymac ~ % cd dev
dave@mymac dev %


/Users/dave % cd dev
/Users/dave/dev %

Step 1: Inspect the current prompt format.

echo $PS1
%n@%m %1~ %#

You can use this information to make gradual changes if you want. Here is the meaning of the variables:

%n  - username
@   - literal at sign
%m  - hostname
%1/ - trailing directory
%1~ - trailing directory, replaces home directory with ~
%#  - # for a privileged shell or % for an unprivileged one

Replace the prompt with the full path.

PS1='%d %# '

Save the file and open a new terminal. The prompt now shows the full path.

Comments in Shell file.

A hash character is used to comment out lines in the shell file.

#PS1='%n@%m %1/ %# '
PS1='%d %# '

I just added the commented line for reference purposes. If you want the default ZSH prompt back, just delete the PS1 variable from the script. Restart the terminal and everything is as before.

Written by Loek van den Ouweland on 2022-03-26.
Questions regarding this artice? You can send them to the address below.