Thursday, February 14, 2013

Linux terminal prompt (PS1)

I wanted to change a little bit on appearance of my terminal prompt. Don't need username and host to see but the path should be clean and clear. Also if there is a big path I find it hard to make commands. So need the path upside and the command just below that. Again some times I go root user, so lets make root user as red and normal user as green. Get my favourite PS1:

For normal user add the following line at the end of /home/<user>/.bashrc
# My custom prompt for normal user
PS1="\[$(tput setaf 2)\]\n[\w]\n# \[$(tput sgr0)\]"

Example output:
[~/path/to/dir]

For root user add the following line at the end of /root/.bashrc
# My custom prompt for root user
PS1="\[$(tput setaf 1)\]\n[\w]\n# \[$(tput sgr0)\]"

Example output:
[/etc/path/to/dir]

How is that :) ?


No comments:

Post a Comment