Link to home
Start Free TrialLog in
Avatar of kravella
kravella

asked on

changing the prompt

How can I change my '$'prompt to any other prompt.I heard that it is done by using .cshrc file.How to access it ?Give me a step by step method from the time of login.
Avatar of ozo
ozo
Flag of United States of America image

echo 'set prompt="any other prompt"' >> ~/.cshrc
man csh
Avatar of pagladasu
pagladasu

You mentioned $ prompt - so are you using the Korn shell or Bourne shell?
I asumed csh, since kravella asked about .cshrc,
But you're right, we should verify which shell is being used.
Avatar of kravella

ASKER

Adjusted points to 100
I was just wondering - the $ prompt is generally no the default one in C shell.
ASKER CERTIFIED SOLUTION
Avatar of pagladasu
pagladasu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here's something that I use in my .profile file.
I am using Korn shell.

dasu(){
  cd $1
  PS1="`pwd`>"
}
alias cd=dasu
cd

to pagladasu:

The Korn shell variable, $PWD is set by ksh to be the current value of pwd.  You can verify this by "echo $PWD" from the shell prompt.  So, to set your prompt to be the current working directory in the Korn shell, without declaring an alias, you can use the following in your .profile;

export PS1="\$PWD>"

Cheers,  

--frankf
to frankf - righto, it works.
pagladasu

As the System prompt is held in variable PS1.

Edit either /etc/profile  - to define same prompt for all users or  .profile in home directory of a user

and define variable PS1, ie

PS1='$PWD) '
export PS1

This shows current dir (like dos prompt).
you have to export it to make it valid in sub-shells.

If you want to display hostname as well you can define something like :

HOST=$(hostname)    - Korn shell only OR
HOST=`hostname`
PS1='[$HOST] - $PWD > '
export PS1