By Manny Fernandez

September 21, 2018

Removing computer name from my bash prompt

OK, I finally broke down and removed the computer name from my bash prompt. It is truly annoying and useless to see it on my screen. This reminds me of customer’s naming conventions where they insits on putting the company name in the host name.

Here is my prompt from before. As you can see, it contains ‘Mannys-MacBook-Pro’. Why? I don’t know. I know what computer I am on. I guess it would be useful if I ssh into another server but normally not of any valure (IMHO)

As you can now see, the only thing left is my name. I may shorten that even 🙂

Here is what I did:

Step 1 – You need to create a file in your home directory if it is not already there (not there by default)

1A – Launch your terminal app. I use iTerm2 because I have since I drank the Apple juice.

cd ~
vi .bashrc

Step 2 – Now you need to enter the edit mode by typing ‘i’ (without the single quotes) and enter the following

PS1=‘\u:\w\

Hit ‘Esc’ then enter ‘:x’ to save the file.

Step 3 – To active the .bashrc file you will need to type the ‘source’ command.

source ~/.bashrc

you should now see the prompt with just the name.

If you close the terminal and re-open it, you will notice that the prompt went back to the original state. If you cat your .bashrc file, you will see that your ‘PS’ statement.

Step 4 – You will need to edit or create (if not already there) a ~/.bash_profile file

sudo vi ~/.bash_profile

hit ‘i’ without the single quote to enter into edit mode and enter the source command you typed earlier.

source ~/.bashrc

Hit ‘Esc’ then enter ‘:x’ to save the file.

All set. I found Nathaniel Landau’s blog post containing some wicked .bash_profile examples. This is a good source to get some ideas.

Leave a comment

Your email address will not be published. Required fields are marked *

Recent posts

  • There are many options when troubleshooting in FortiGate firewalls. ... Full Story

  • Have you ever had an IPS signature that continues... Full Story

  • Use case:  Customer has a Split Tunnel Enabled but... Full Story