Sunday, July 5, 2009

Setting Terminal Prompt in OS X Leopard

When working with a slew of terminal sessions with each connected to different hosts and as different users, the default terminal prompt in Leopard is useless, and IMHO, dangerous when you are root after doing a 'sudo -s'. As root, it is impossible to tell what host you are on and that is a recipe for disaster.

To customize your terminal prompt in Leopard for regular users and root user, simply add the following line to both ~/.bashrc and ~/.profile:

export PS1="\\u@\\h:\\w\\$ "

Your prompt will now look something like this for regular and root user:

kieran@kieranmacpro:~$ sudo -s
Password:
root@kieranmacpro:~#

1 comments:

Paolo said...

Thanks, I was looking for this!

Post a Comment