Hide Computer and User Names in Terminal/Command Prompts

I'm setting up a new MacBook, and before recording, I like to hide the generic information in the terminal.

This can be easily achieved by editing shell configuration files like .bashrc or .zshrc.

Here's how:

For Bash Users

  1. Edit the .bashrc File: Open your terminal and run nano ~/.bashrc to edit the Bash configuration file.
  2. Customize the Prompt: Add the following line to the end of the .bashrc file:
export PS1="\W \$"

This command changes the prompt to display only the current directory (\W) followed by a dollar sign ($). This setting simplifies the prompt to show just the dollar sign ($), removing user or host information.

  1. Apply the Changes: Save the changes and exit the editor. You may need to reload the .bashrc file by typing source ~/.bashrc.

Troubleshooting

Depending on your system setup, if changes do not take effect, you might need to add or edit the .bash_profile to include sourcing .bashrc. For detailed guidance on when to use .bash_profile over .bashrc. You might need to check the docs if you are struggling with this.

For Zsh Users

  1. Edit the .zshrc File: Open the Zsh configuration file in the terminal by running nano ~/.zshrc.
  2. Modify the Prompt: At the end of the .zshrc file, add:
export PS1="\$ "

This setting simplifies the prompt to show just the dollar sign ($), removing any user or host information. 3. Save and Source: After saving the file, apply the changes by sourcing it with source ~/.zshrc.

I hope this helped!

Terminal
Avatar for Niall Maher

Written by Niall Maher

Founder of Codú - The web developer community! I've worked in nearly every corner of technology businesses; Lead Developer, Software Architect, Product Manager, CTO and now happily a Founder.

Loading

Fetching comments

Hey! 👋

Got something to say?

or to leave a comment.