Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!mailrus!ames!ncar!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: A blank line before the unix prompt? Keywords: prompt Message-ID: <12934@mimsy.UUCP> Date: 10 Aug 88 03:35:46 GMT References: <3809@okstate.UUCP> <6591@bloom-beacon.MIT.EDU> <1236@ficc.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 58 In article <1236@ficc.UUCP> spenser@ficc.UUCP (spenser aden) writes: >alias cd 'cd \!* ; set prompt=""`pwd`" \ >(\!) " ' # set prompt string (The s are ESC [ = 5 h and ESC [ = 5 l, but ESC characters disappear over USENET. Good thing too. :-/ ) >... This works fine when I first login and until I try to 'cd' to >any directory, but when I try to 'cd' it says 'Unmatched "."' and the >'cd' fails. I suspect that it's not able to carry the alias over to >the second line using the \ method spelled out in the previous article .... The solution for about half the problems with the C shell is the same: Use more \ characters. You have to write alias cd 'cd \!* ; set ... \\ ... ' so that the alias itself has one \ in it. Some years ago, Fred Blonder and I were experimenting with working- directory prompts. The regular sorts of wd prompts were not hard, but we wanted to get `~' compression, so that one would see, e.g., [~] ==> cd /tmp [/tmp] ==> cd [~] ==> cd foo/bar [~/foo/bar] ==> cd baz [~/foo/bar/baz] ==> Unfortunately, csh insisted on expanding the `~' whenever we ran the output of `dirs' through awk to get the first string. Quoting helped: here is what we came up with (his version): alias set_prompt 'set prompt = '"'"'['"'"'"`dirs|awk '"'"'{print "\$1"}'"'"'`"'"'"'] ==> '"'"'' alias cd '\!:0-$; set_prompt' alias pushd '\!:0-$; set_prompt' alias popd '\!:0-$; set_prompt' set_prompt After some thought, I reduced this (after changing the style) to alias set_prompt 'set prompt="[\\!] `dirs|awk '\''{print "\$1"}'\''` "' alias cd 'cd \!*; set_prompt' alias pushd 'pushd \!*; set_prompt' alias popd 'popd \!*; set_prompt' set_prompt Of course, for faster operation, one can write set prompt=(`dirs`) but again csh insists on expanding `~'.... -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris