Hide your computer name in ZSH/BASH
Learn how to change your Terminal prompt
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:
- 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.
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!
- *Disclaimer*: This article is inspired by https://stackoverflow.com/questions/31848957/zsh-hide-computer-name-in-terminal