Saturday, May 28, 2011

Setting custom Prompt

As much as I know maximum linux family's users were Windows users previously or using Linux parallel with Windows/Mac OS. I was too a Windows user previously, now fully switched to Linux.
In Windows, we have seen prompt command in command prompt(cmd) to change the prompt of the cmd.

Today I am going to discuss about same thing for linux.
In Linux, PS1 shell variable sets the prompt. We can use this variable to set our own custom prompt with the use of special escaped sequences.
Here, are few common escape sequences:
\h - short hostname
\u - username
\w - current working directory
\! - history number of the current command
\$ - this shows the privilege i.e for root users # and for non-root users $
Setting custom prompt using special escaped sequences:
1. temporary change:
$ PS1="\u@\h: \w \$" this will give you prompt something like this:
prabindatta@localhost: /home/prabindatta $

2. to make this change permament:
$ vi /.bashrc
at the end append your line something like this:
PS1='\u@\h: \w \$'

1 comment:

  1. Thanks to update your past. I search blog exactly appear to your blog. Yes I agree this is very powful content. Bye Regards Web To Print