Changing the prompt in CSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Changing the prompt in CSH
# 8  
Old 09-27-2013
HI.

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

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

on system:
Code:
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:
Code:
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 https://www.unix.com/unix-dummies-que...3-csh-pwd.html seems to work well.
Code:
alias cd 'cd \!*;set prompt="[`hostname`]$cwd :" '

Best wishes ... cheers, drl
This User Gave Thanks to drl For This Post:
# 9  
Old 09-27-2013
The below code works now for only one time . When i change the directory it doesnt update the path . Any ideas.

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

# 10  
Old 09-27-2013
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.
This User Gave Thanks to Corona688 For This Post:
# 11  
Old 09-27-2013
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
Code:
$cwd

.Thank you for suggestion here .
# 12  
Old 09-27-2013
Could you try the following:-
Code:
ps -f
ksh
ps -f
bash
ps -f

...... and post the output.



Robin
# 13  
Old 09-27-2013
Code:
<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

# 14  
Old 09-27-2013
I'm not so sure you did, since it suggests %/ for tcsh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing script from csh to bash

Hello Guys I have a script working fine on csh, but I would like to change it to bash, how I should change this command to be able to work as bash script. :wall: if ( $fsw > "0" ) then foreach swath ( `awk 'BEGIN {for (i='$fsw';i<='$lsw';i++) printf ("%s\n", i) }'` ) ## work to be done... (2 Replies)
Discussion started by: jiam912
2 Replies

2. UNIX for Dummies Questions & Answers

Problem in C shell (csh) prompt setting containing the '$' char

Hi, I am trying to customize the command prompt of the C shell as follows: set prompt=" " The above one works fine but when I try to add a '$' (dollar) symbol into the string as set prompt=" " I am getting the error as: Illegal variable name However, this one set prompt = "-- %T %n %~ --... (2 Replies)
Discussion started by: royalibrahim
2 Replies

3. Shell Programming and Scripting

Changing the file name to a different one using csh

I have a file name n10-z30-dsr65-ndelt1.00-varp0.08-16x12drw-csq-msf.ps and I want to remove the varp info tag to get n10-z30-dsr65-ndelt1.00-16x12drw-csq-msf.ps Trying to use tr, but when I tried replacing varp with ooo I am getting the results below: echo... (2 Replies)
Discussion started by: kristinu
2 Replies

4. Shell Programming and Scripting

Changing the shell prompt

Hi, I want to change the shell prompt, using the cd command. I have a shell prompt like this - p78-mfx(dgaw1078/9781)$ Now i do this - p78-mfx(dgaw1078/9781)$ cd log4j here the shell prompt should change like this - p78-mfx(dgaw1078/9781)log4j$ (6 Replies)
Discussion started by: arunkumarmc
6 Replies

5. Shell Programming and Scripting

tcsh/csh: set prompt in production to color red

Hi folks This is our prompt at the moment oracle@pinkipinki:/opt/oracle> grep 'set prompt' .cshrc set prompt = "$user@`uname -n`:$cwd> " We wish to have in production the same prompt, but red. Howto do that? I tried a lot a internet manuals, but it doesn't work. (1 Reply)
Discussion started by: slashdotweenie
1 Replies

6. UNIX for Advanced & Expert Users

Changing the password prompt

Is there any way I can change the prompt which asks for the password on a UNIX system? e.g. When I login using Telnet instead of "Password" I should get "Correct Password". Thanks, Vineet (3 Replies)
Discussion started by: vineetd
3 Replies

7. Solaris

Changing prompt

I currently have this as my prompt when I log in (shell is sh): PS1="`hostname ` # " My question is how do I add the current directory to that prompt? Is there a way? Thanks. (5 Replies)
Discussion started by: kjbaumann
5 Replies

8. UNIX for Dummies Questions & Answers

Changing Prompt in sh

I know no one has ever asked this before {not :D } but I am trying to set the prompt in the .profile under sh. I have tried everything I have seen on the web in regards to this, with no success. The OS is SCO Unixware 7.1.1, {not by my choice}. All the examples I see seem to be for ksh, which is... (1 Reply)
Discussion started by: jcc5169
1 Replies

9. UNIX for Dummies Questions & Answers

Changing the prompt

Phew simple question, I want to display the my directory path in prompt. Did the following in .profile PS1=`pwd` export PS! Worked, but it always points to HOME directory. When i do a cd, it doesn't change. What am i missing. Thanks (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

10. Shell Programming and Scripting

current directory as part of the csh prompt

I would like my csh prompt to behave like the linux csh prompt setting done by linux command (set prompt="%n@%m %c]$ ") how do I do that? What I'm trying to do is that I would like to see what directory I'm in by looking at the prompt. I've figured out that %n is like $user, and %m is like... (3 Replies)
Discussion started by: jamesloh
3 Replies
Login or Register to Ask a Question