Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!burl!codas!ki4pv!hropus!jgy From: jgy@hropus.UUCP Newsgroups: comp.unix.questions Subject: Re: prompt wars Message-ID: <913@hropus.UUCP> Date: Thu, 19-Mar-87 11:15:21 EST Article-I.D.: hropus.913 Posted: Thu Mar 19 11:15:21 1987 Date-Received: Sun, 22-Mar-87 23:44:57 EST References: <1480@umd5> <5823@mimsy.UUCP> <5873@mimsy.UUCP> Organization: Bell Labs, Holmdel, NJ Lines: 30 > In article <5823@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: > > > Instead of using a shell script and awk, it is much faster to do this: > > > set hostname=`hostname | sed -e 's/\..*//'` > > alias set_prompt 'set prompt="${hostname}[\\!] `dirs|cdt2` % "' > > > Likewise, using `sed' to change `/usr/spool/news/comp/unix/questions' > > to `...unix/questions' is also faster, and if done in an alias rather > > than in a shell script, should be as fast as the C program Ben wrote. > > The sed commands to do this are left as an exercise to the reader. :-) > > Well, this alias seems to do the trick. It seems a little slow, but this > is mimsy rather than umd5 so I don't have the basis for comparison... > > alias set_prompt 'set prompt="`hostname|sed -e '\''s|\..*||'\''`[\\!] `dirs|sed -e '\''s| .*||'\'' -e '\''s|.*[^/]\(/[^/]*/[^/]*\)|...\1|'\''` % "' > > It could probably be decomposed in the way Chris suggests... For korn shell users to get the prompt set to the machine name without need for ANY new processes (after setting your machine name) so.... In your .profile add: UNAME=`uname` export UNAME alias -xt set_prompt='cd ../..;_x=$PWD;cd -; PS1="$UNAME!!...${PWD#$_x} "' That's it, no new processes, and hopefully only two system calls executed by KSH (2 chdir's), each time you do a set_prompt.