Currently in my Terminal, every shell prompt looks like ComputerName: FooDir UserName$
. The UserName
part simply wastes too much space out of my precious 80 columns. Is there a way to suppress it?
To make any change to the default zsh prompt, you'll have to add relevant values for the prompt to appear differently than the default. It'll be blank if you're accessing it for the first time. You can add a new line with the text PROMPT='...' and include relevant values in the ellipses.
The window contains a prompt that indicates you can enter a command. The prompt you see depends on your Terminal and shell preferences, but it often includes the name of the host you're logged in to, your current working folder, your user name, and a prompt symbol.
The prompt is defined by the environment variable PS1
which you can define in .bash_profile
.
To edit it, open or create the (hidden) file .bash_profile
:
nano .bash_profile
and add a line that says
export PS1=""
Between the quotation marks, you can insert what you would like as your terminal prompt. You can also use variables there:
\d
– date\t
– time\h
– hostname\#
– command number\u
– username\W
– current directory (e.g.: Desktop)\w
– current directory path (e.g.: /Users/Admin/Desktop)The default prompt for common Linux distributions would be \w $
, which evaluates to ~ $
in your home directory or e.g. /Users $
somewhere else. There are also website (like this one) that can help you with building your prompt.
If you want to remove the UserName
part, your choice would be \h: \w$
.
Once you made your changes, save the file with Control+o, Return, Control+x.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With