Saturday, 5 January 2013

Change Command Prompt

  Command Prompt is a non-graphical interface that allows you to interact with your operating system. This article deals with changing command Prompt in openSUSE 12.2 , GNOME 3.4.2. The command prompt in Unix is the famous '$'.The default command prompt in openSUSE looks like the following screenshot.
Default Command Prompt openSUSE
 The openSUSE command prompt contains information about the current user  (mantis), Host Name (linux-u7wa), Current working directory (~) which is the home directory indicator. Since the command prompt is dynamic in nature, when one changes directory the prompt also changes. Fox example if you navigate to Desktop directory then the command prompt will also change accordingly as shown below.
Dynamic Command Prompt
 In Linux the command prompt is defined in a variable called "PS1". When we run the echo against variable PS1 it will display its value. The contents of PS1 will look something like $(ppwd \l)\u@\h:\w>
echo PS1
 We can change the command prompt by changing the value in variable PS1. To change prompt to '$'  we can use the command (PS1=$) as shown below.
set PS1 value
 But setting the variable value in terminal is not permanent in nature. The command prompt will revert back to default value after the terminal is closed. To change the prompt to '$' every time you open the terminal, you need to locate the file ".bashrc" in home folder and add a line (PS1=$) at the end of the file as shown below.
set PS1 bashrc
 If you want to retain the dynamic prompt with minor changes then you need to add the line (PS1="$(ppwd \l)\u@\h:\w$") in the file ".bashrc". Here the '>' at the end is replaced by a '$' in the default prompt.
set PS1 bashrc change dynamically variable
Also check out:- Changing Root Command Prompt