How to Change the User's Prompt


Question:
"When I log in, I see myusername on ce.uml.edu>
How do I change this prompt to a %? "
Answer:  You need to edit your initialization file, which depends on the shell you are using.
As part of the log-in sequence, all the shells read a global default initialization file that contains environment variables and commands before running the user account private shell initialization file, which is in the user's home directory.
In the users home directory there are the following initialization files:
  • .cshrc
  • .login
  • .profile

The Bourne, Korn and Bash shells all read the /etc/profile first, then the user's local .profile. If you are using one of these shells as your login shell, you would edit your .profile.
For example :

  •   if you want your prompt to be a % instead of username on ce.uml.edu> , use VI or emacs to edit the .profile  in your directory.
    Change the line PS1="$user on `hostname`> " to "PS1="%".
     
  • If you want to put the current working directory in your path,  set PS1='$PWD> ' 
    It is important that you use single quotes, since the $PWD will be evaluated when the PS1 is displayed.

    If you used double quotes, the $PWD would be the value when the PS1="$PWD> " line was read.

The C shell uses the /etc/csh.login file for initialization before reading the user's .cshrc and .login files. If you are using the C shell, you would edit the .login file to change your prompt. Use VI or emacs to edit the file. Change the line set prompt="$user on `hostname`> " to set prompt="%".