A blank line before the unix prompt?
Chris Torek
chris at mimsy.UUCP
Wed Aug 10 13:35:46 AEST 1988
In article <1236 at ficc.UUCP> spenser at ficc.UUCP (spenser aden) writes:
>alias cd 'cd \!* ; set prompt="<stuff>"`pwd`"<stuff> \
>(\!) " ' # set prompt string
(The <stuff>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 at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.questions
mailing list