Changing the prompt in CSH

Need assistance in changing prompt .

Trying to change prompt in csh,tcsh shell . Below are the commands i tried in .cshrc and sourcing this files.

set prompt = "$user@`uname -n` : ${cwd}> "

#above commands works for username and hostname but cwd doesnt change
directories

set prompt = "$user@`uname -n` : ${cwd}> "
set prompt  = '%B%m%b %c3 %# '

#this isnt working either

Any ideas appreciated . Thank you

set prompt = `hostname | awk -F. '{print $1}'`"$PWD>

Putting $CWD in backticks won't stop $CWD from evaluating before the prompt is ever shown. Try \$ if csh lets you do that

No luck :frowning:

set prompt  = '%B%m%b %c3 %# '

Does seem to work (tested in CSH on OS X and on CentOS).

What OS are you using, and what does not work about it?

SunOS <servername> 5.10 Generic_127111-09 sun4u sparc SUNW,SPARC-Enterprise

the above commands doesnt change to username,hostname.

After setting the path i get the same result

%B%m%b %c3 %#

---------- Post updated at 02:04 PM ---------- Previous update was at 01:33 PM ----------

Appreciate if someone can help me on this !!!!

The best help I can give you is...

Don't use C-Shell. This is 2013, not 1983 :slight_smile:

1 Like

HI.

In systems other than Solaris, csh is often tcsh, another kettle of fish altogether.

The code:

set prompt = "$user@`uname -n` : ${cwd}> "

on system:

OS, ker|rel, machine: SunOS, 5.10, i86pc
Distribution        : Solaris 10 10/08 s10x_u6wos_07b X86
csh Aug 8 2006 (SunOS 5.10)

produced a prompt:

drl@vm-solaris : /home/drl>

However, changing directories does not change the prompt.

You may wish to look at HOWTO: Change your Shell Prompt for some tips on changing the prompt in many different shells including csh.

Best wishes ... cheers, drl

---------- Post updated at 08:23 ---------- Previous update was at 07:24 ----------

Hi.

Noting that directory tracking is often desired, this alias from csh - pwd seems to work well.

alias cd 'cd \!*;set prompt="[`hostname`]$cwd :" '

Best wishes ... cheers, drl

1 Like

The below code works now for only one time . When i change the directory it doesnt update the path . Any ideas.

set prompt = "$user@`uname -n` : ${cwd}> "

Did you try my suggestion? I see no indication that you did.

Did you read DRL's link? I see no indication that you did. There are suggestions in there you have not tried, and begging for more while ignoring the answers you have does not paint you in a good light.

In any case, don't use C-shell. It is broken and flawed, as an unfortunate fact, not a matter of opinion.

1 Like

as a matter of fact i have gone through the links and worked around it.

i have lot of thinks in the .cshrc for csh . Thats the only reason i am using csh

only thing here it doesnt work is it doesnt change the path when you change

the directory for

$cwd

.Thank you for suggestion here .

Could you try the following:-

ps -f
ksh
ps -f
bash
ps -f

...... and post the output.

Robin

<hostname>% ps -f
     UID   PID  PPID   C    STIME TTY         TIME CMD
  <user>  8607  7765   0 10:33:27 pts/4       0:00 csh
  <user> 22277 28940   0 10:58:07 pts/4       0:00 ps -f
  <user>  7765  7759   0 10:33:19 pts/4       0:00 -bash
  <user> 28940  8607   0 10:41:28 pts/4       0:00 /bin/csh
<hostname>% ksh
$ ps -f
     UID   PID  PPID   C    STIME TTY         TIME CMD
  <user> 25794 28940   0 10:58:27 pts/4       0:00 ksh
  <user> 26495 25794   0 10:58:31 pts/4       0:00 ps -f
  <user>  8607  7765   0 10:33:27 pts/4       0:00 csh
  <user>  7765  7759   0 10:33:19 pts/4       0:00 -bash
  <user> 28940  8607   0 10:41:28 pts/4       0:00 /bin/csh
$ bash
[<user>@<hostname ~]$  ps -f
     UID   PID  PPID   C    STIME TTY         TIME CMD
  <user> 25794 28940   0 10:58:27 pts/4       0:00 ksh
  <user> 28083 27120   0 10:58:40 pts/4       0:00 ps -f
  <user>  8607  7765   0 10:33:27 pts/4       0:00 csh
  <user>  7765  7759   0 10:33:19 pts/4       0:00 -bash
  <user> 28940  8607   0 10:41:28 pts/4       0:00 /bin/csh
  <user> 27120 25794   0 10:58:34 pts/4       0:00 bash

I'm not so sure you did, since it suggests %/ for tcsh.

Corona688. Can you please give me the full statement with

%/

for

set prompt = "$user@`uname -n` : ${cwd}> "

Instead of ${cwd}, try %/

Tried it and below is the result.

<user>@<hostname> : /local/home/<user> > set prompt = "$user@`uname -n` : %/ >"
<user>@<hostname> : %/ >