laba-3hd@e260-3a.berkeley.edu (Sam Shen) (02/06/89)
I like to keep my current directory in my prompt. I do it like this: (e260-3a) laba-3hd % alias cd cd !*; prom (e260-3a) laba-3hd % alias prom set prompt = "($host) ""$cwd:t"" % " Where $host is the hostname (I'm on a cluster of about 60 Suns, so it's easy to forget which one you're on) and $cwd is of course the current directory. Unfortunately, when I do this: (e260-3a) laba-3hd % mkdir '*' (e260-3a) laba-3hd % cd '*' My prompt becomes: (e260-3a) * /usr/wolf/c60a-3/sp89/laba-3hd/60a /usr/wolf/c60a-3/sp89/laba-3hd/Mail /usr/wolf/c60a-3/sp89/laba-3hd/News /usr/wolf/c60a-3/sp89/laba-3hd/awk /usr/wolf/c60a-3/sp89/laba-3hd/bin /usr/wolf/c60a-3/sp89/laba-3hd/go_away /usr/wolf/c60a-3/sp89/laba-3hd/pic /usr/wolf/c60a-3/sp89/laba-3hd/priv /usr/wolf/c60a-3/sp89/laba-3hd/ps /usr/wolf/c60a-3/sp89/laba-3hd/src % (I put newlines in the prompt so it wouldn't be one long line.) Whereas I want my prompt to be: (e260-3a) * % How do I do this? Sam Shen laba-3hd@web.berkeley.edu
laba-3hd@e260-3a.berkeley.edu (Sam Shen) (02/06/89)
(I wrote in a previous article about how I keep the current directory in my prompt and if I cd into a directory named * I get a wildcard expanded prompt.) I worked on this for about 45 mins several days ago and, believe it or not, silly me thought of the answer about 2 hours after I posted. Oops. Anyhow, if I do alias cd "set noglob; chdir \!*; prom; unset noglob" It works. It has to be chdir by the way. If it's cd then the csh thinks it's an Alias Loop. Sam Shen laba-3hd@web.berkeley.edu
jik@athena.mit.edu (Jonathan I. Kamens) (02/06/89)
In article <20005@agate.BERKELEY.EDU> laba-3hd@e260-3a.berkeley.edu (Sam Shen) writes: >I like to keep my current directory in my prompt. I do it like this: > >(e260-3a) laba-3hd % alias cd >cd !*; prom > >(e260-3a) laba-3hd % alias prom >set prompt = "($host) ""$cwd:t"" % " > >... > >[Problems with a directory named *... why would anybody want a > directory named *? Anyway...] This'll do the trick, I think: (pit-manager) src % alias cd chdir !*; set noglob; prom; unset noblob (pit-manager) src % alias prom set prompt = "($host) ""$cwd:t"" % " (pit-manager) src % mkdir '*' (pit-manager) src % cd '*' (pit-manager) * % Jonathan Kamens USnail: MIT Project Athena 410 Memorial Drive, No. 223F jik@Athena.MIT.EDU Cambridge, MA 02139-4318 Office: 617-253-4261 Home: 617-225-8218
pme@umb.umb.edu (Paul English) (02/07/89)
Since this type of thing usually makes your prompt so long that you usually tend to ignore it, why have it there in the first place? If you really need an easy way of reminding yourself where you are, you could do something like the following to make it easy to get this info on demand: alias . echo `hostname`: `dirs` Of course if you are running under a decent windowing system, you should have this info in your window header. This is also an easy (and documented in many places) thing to do. -- Paul M. English, UMass/Boston CS grad. pme@umb.edu, husc6!umb!pme, harvard!umb!pme
mgb@huelings.harvard.edu (Michael G. Burner) (02/07/89)
How about: alias ncd 'set noglob; cd \!*; unset noglob' Of course this means learning to use "ncd" instead of "cd", but anyone who wants to name a directory "*" is obviously willing to put up with alot to do so. --Mike
jik@athena.mit.edu (Jonathan I. Kamens) (02/08/89)
In article <20008@agate.BERKELEY.EDU> laba-3hd@e260-3a.berkeley.edu (Sam Shen) writes:
=(I wrote in a previous article about how I keep the current directory
= in my prompt and if I cd into a directory named * I get a wildcard
= expanded prompt.)
=
=...
=
=alias cd "set noglob; chdir \!*; prom; unset noglob"
Great minds think alike, I think :-).
Jonathan Kamens USnail:
MIT Project Athena 410 Memorial Drive, No. 223F
jik@Athena.MIT.EDU Cambridge, MA 02139-4318
Office: 617-253-4261 Home: 617-225-8218
crh@ajax.Philips.Com (Charles Hill) (02/08/89)
In article <739@umb.umb.edu> pme@umb.edu (Paul English) writes: >Since this type of thing usually makes your prompt so long that you >usually tend to ignore it, why have it there in the first place? If >you really need an easy way of reminding yourself where you are, you >could do something like the following to make it easy to get this info >on demand: > > alias . echo `hostname`: `dirs` > I agree. While my host names are short so they are OK to embed in the prompt, I would find having the full dir pathname in the prompt very annoying. I agree it's better to just make it quick to find out where you are. Moreover, the posted solutions for embedding the cwd in the prompt ignore "pushd", which I find especially useful for frequently switching back and forth among a set of directories. I use the following aliases: alias pd pushd alias 1 dirs alias 2 pushd alias 3 pushd +2 alias 4 pushd +3 Typing 1 quickly tells me where I am. Typing another number such as 3 brings the 3rd element to the top of the dir stack. Charles Hill Philips Labs (crh%philabs.philips.com@uunet)