How to change your SHELL prompt – OSX | UNIX | Linux
If you don’t like your shell prompt showing the hostname and the username, you can change the way it looks.
You will need to edit your login script for this, each and every shell has their own, if you are using bash, then you need to edit .bashrc, it’s a dotted file so it’s hidden, it’s located right in your home folder. Just enter the command.
$nano ~/.bashrc
For the OSX users, you should edit ~/.profile
if you didn’t install nano just use any editor that you have (vi, emacs, gedit, pico etc).
Go the last line of file and add the lines;
export PS1=” “
if you actually use this setting, you will not have a prompt, not even the dollar sign (for some this might appeal, I actually use this), if you want to put something else, just type it in between the ” “. Here are some of the things yo u can put in there.
\h – Host name
\# – Command number
\u – User name
\W – Current working directory (ie: Desktop/)
\w – Current working directory, full path (ie: /Users/Admin/Desktop)
\d – Current date
\t – Current time
if you want your prompt to show username [at] machinename [dollar sign], then do this
export PS1="\u@\h$"
Close the editor, (CTRL-O, then CTRL-X in nano), close the terminal session, and get another terminal session — you have to do this for the changes in the login script to kick in.
You should have a modified shell now, this is mine.
If you want to show appreciation for my efforts dear reader, you could buy me a tall hazel nut Americano ($2) via PayPal. Thanks
Leave a comment