Hide your computer name in ZSH/BASH

Learn how to change your Terminal prompt

Daniel Chu
Mac O’Clock
2 min readDec 5, 2019

--

Coming to an end of 2019! What a year~

Some updates for Mac user, with macOS Catalina 10.15, Apple is now using Zsh as the default shell.

From my personal experience, there is no major change when switching from bash shell → zsh shell. Of course, now the shell script file changed from .bashrc .zshrc as well.

The moment you open the terminal, .zshrc execute first and your computer name come out!

If you wish to change the computer name/ username, do the following steps:

  1. Open your terminal and select Preferences .

2. Click on Profiles tab, go to Shell tab and activate Run command and Run inside shell .

3. Put the command in text area, export PS1="[ `whoami` ~]$ "; clear;

4. Close the Profiles tab and open a new tab of your terminal/ reopen your terminal.

*Computer name hidden!*

5. “Da Dang”, your computer name is gone! In fact, you can change anything or any name you want in the terminal!

6. If you wish to use iTerm2 and integrate with zsh shell, take a look at this article: https://www.freecodecamp.org/news/how-to-configure-your-macos-terminal-with-zsh-like-a-pro-c0ab3f3c1156/

That’s all! See you next time!

--

--