news@massey.ac.nz (USENET News System) (02/05/91)
Let's assume a csh invoked from a csh. How do keep track of how far down the track, one is? Let's say one has recursively invoked csh, it should be possible to discover how far down one is. How does one do it? Thanx Raminder $ingh Phone : +64 63 69 099 X 7772 Computer Centre MASSEY UNIVERSITY Fax : +64 63 505 607 Palmerston North NEWZEALAND E-mail: R.Singh@massey.ac.nz
subbarao@rise.Princeton.EDU (Kartik Subbarao) (02/05/91)
In article <1991Feb5.000455.9976@massey.ac.nz> R.Singh@massey.ac.nz (R. Singh) writes: >Let's assume a csh invoked from a csh. How do keep track of how far down >the track, one is? Let's say one has recursively invoked csh, it should be >possible to discover how far down one is. How does one do it? >Thanx If you have sps, it will show you this information in a nice format. Still, ps gives you the same information, and you'll just have to look at the output to see how many csh's have been invoked. -Kartik -- internet# find . -name core -exec cat {} \; |& tee /dev/tty* subbarao@{phoenix or gauguin}.Princeton.EDU -|Internet kartik@silvertone.Princeton.EDU (NeXT mail) -| SUBBARAO@PUCC.BITNET - Bitnet
fwp1@CC.MsState.Edu (Frank Peters) (02/05/91)
In article <1991Feb5.000455.9976@massey.ac.nz> news@massey.ac.nz (USENET News System) writes:
Let's assume a csh invoked from a csh. How do keep track of how far down
the track, one is? Let's say one has recursively invoked csh, it should be
possible to discover how far down one is. How does one do it?
Thanx
Csh doesn't come with any built in way but its pretty trivial to add.
Put the following code in your .cshrc file:
if ( $?cshlevel == 0 ) then
setenv cshlevel 1
else
setenv cshlevel `expr $cshlevel + 1`
endif
This checks to see if cshlevel is set. If not it sets it to one. If
it is set then it is incremented by one.
FWP
--
Frank Peters Internet: fwp1@CC.MsState.Edu Bitnet: FWP1@MsState
Phone: (601)325-2942 FAX: (601)325-8921
boyd@necisa.ho.necisa.oz.au (Boyd Roberts) (02/06/91)
>In article <1991Feb5.000455.9976@massey.ac.nz> R.Singh@massey.ac.nz (R. Singh) writes: >Let's assume a csh invoked from a csh. How do keep track of how far down >the track, one is? Let's say one has recursively invoked csh, it should be >possible to discover how far down one is. How does one do it? >Thanx > Back in the dim distant past I used to have my prompt set to indicate how many C shells I had and whether they were root shells or me (now that's _quite_ a while back -- ugh -- the horrors of C shell). I have since returned to the fold and use a V8 style Bourne shell. I had this variable $cshdepth which had a `#' or `%' appended to it in my .cshrc depending on the uid of the shell. $cshdepth would then set part of my prompt, so I'd get a display like this: 1% /bin/su Password: # exec csh 1%# You get the idea? Boyd Roberts boyd@necisa.ho.necisa.oz.au ``When the going gets wierd, the weird turn pro...''
nto0302@dsacg3.dsac.dla.mil (Bob Fisher) (02/07/91)
From article <1991Feb5.000455.9976@massey.ac.nz>, by news@massey.ac.nz (USENET News System): > Let's assume a csh invoked from a csh. How do keep track of how far down > the track, one is? Let's say one has recursively invoked csh, it should be > possible to discover how far down one is. How does one do it? The following prefixes a "." to the prompt each time you invoke a new C shell. You get a visual reminder each time you get your prompt. set prompt="${LEVEL} %! => " setenv LEVEL ".${LEVEL}" -- Bob Fisher US Defense Logistics Agency Systems Automation Center DSAC-TOL, Box 1605, Columbus, OH 43216-5002 614-238-9071 (AV 850-9071) bfisher@dsac.dla.mil osu-cis!dsacg1!bfisher
rg@msel.unh.edu (Roger Gonzalez) (02/07/91)
I don't have anything that just prints your arbitrary csh level, but this handles a couple important cases: From the default .cshrc I set up new users to source in /: ---- if ($?prompt == 0) exit set user = `who am i | cut -d" " -f1 | cut -d\! -f2` set host = `hostname` set prefix = $host':'$user set user2 = `whoami` if ($user2 == 'root') then set suffix = '#' else set suffix = '%' endif if ($user == $user2) then set prompt = $prefix$suffix' ' else set prompt = $prefix' ('$user2')'$suffix' ' endif ---- I realize that this is isn't quite what you want, but I've been asked for this a couple times before. -Roger -- "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim" - Edsgar W. Dijkstra rg@[msel|unhd].unh.edu | UNH Marine Systems Engineering Laboratory r_gonzalez@unhh.bitnet | Durham, NH 03824-3525