liu@jhunix.HCF.JHU.EDU (Xuyong Liu) (10/23/89)
Under the C shell, one can set the prompt to the current working directory by using the following alias: alias cd 'cd \!* ; set prompt = "$CWD: "'. How can this be done under ksh? I tried alias cd='cd $1; PS1="$PWD: " and it did not work. Thanks for any help in advance. liu@alpha.ece.jhu.edu liu@jhunix.UUCP
dold@mitisft.Convergent.COM (Clarence Dold) (10/25/89)
in article <3028@jhunix.HCF.JHU.EDU>, liu@jhunix.HCF.JHU.EDU (Xuyong Liu) says: > How can this be done under ksh? I tried > alias cd='cd $1; PS1="$PWD: " > and it did not work. I don't have an alias for cd. I do have PS1=`uname -n`'_${PWD}_!$ ' which yields: mitisft_/u3/dold_6980$ -- --- Clarence A Dold - dold@tsmiti.Convergent.COM (408) 434-5293 ...pyramid!ctnews!tsmiti!dold P.O.Box 6685, San Jose, CA 95150-6685 MS#10-007
cpcahil@virtech.uucp (Conor P. Cahill) (10/25/89)
In article <3028@jhunix.HCF.JHU.EDU>, liu@jhunix.HCF.JHU.EDU (Xuyong Liu) writes: > alias cd='cd $1; PS1="$PWD: " How about: PS1="\$PWD: " PS1 is re-parsed prior to each use, so the \$ will cause the PWD variable to be expanded at run time, as opposed to definition time. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+
davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (10/25/89)
You have to escape the $ so it's evaluated at display time. PS1='$PWD> ' My personal favorite is: PS!='${PWD#$HOME/}> ' which displays subdirectory only in my login directory, but full pathname elsewhere. Nice to have on the screen if you are ready to do "rm *" -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon
liu@jhunix.HCF.JHU.EDU (Xuyong Liu) (10/27/89)
To all these offered their help: Thanks a lot for your help. I really appreciate it. Now I have a prompt I like. ------ Xuyong Liu liu@alpha.ece.jhu.edu
feustel@well.UUCP (David Alan Feustel) (10/28/89)
Try export PS1='$PWD'} -- E-mail: feustel@well.sf.ca.us FAX: 1-803-854-18121 {ucbvax,apple,hplabs,pacbell}!well!feustel WORK: 1-803-843-1500x4504
mje@olsa99.UUCP (Mark J Elkins) (10/29/89)
From article <3028@jhunix.HCF.JHU.EDU>, by liu@jhunix.HCF.JHU.EDU (Xuyong Liu): Prompts for 'ksh' > How can this be done under ksh? I tried 1) I work on a network of machines - so I like my current machine name in the prompt. 2) I also like the history number. 3) I also want the Current working directory - but I don't want to have a prompt that fills the width of my screen - the last 12(ish) characters of my PWD is all I need. (I know that 'ksh' will horisontally scroll the prompt line if you are in 'raw' mode ...set -o viraw... but....) 4) I like my prompt even when I 'su' to root! My .profile contains... B=`tput smso` # Turn on Standout mode (normally reverse video) N=`tput rmso` # Turn off Standout mode PS0="`uname -n`${B}!${N}" # The root of my prompt ENV=$HOME/.shrc # Where I keep my Env file. PROM='>' export ENV PROM PS0 N B My '.shrc' contains... # --------- Have I su'ed if [ "`id | grep root`" ] then PROM='#' else PROM='>' fi export PROM # ------------ Keep 'ksh' after a 'su' su() { Who=root flag='' if [ $# -gt 0 ] then Who=$1 if [ $Who = '-' ] then Who="$2" flag="$1" fi fi /bin/su $flag $Who -c "exec $SHELL" } # The 'cd' function - This was in Unix World about 18 month ago. function _cd { typeset t1 'cd' $1 if [ ${#PWD} -gt 15 ] then t1="${PWD%/*???????????????}" PS1="$PS0...${PWD#$t1/}$PROM " else PS1="$PS0$PWD$PROM " fi } alias -x cd=_cd PS1="$PS0$PWD$PROM " typeset -fx _cd # ------- End of bright Ideas.o Anyone got a better solution? or a better way of achieving a compatable result? -- /"""\ Mark J Elkins, Olivetti Africa, Unix Software Support |o.o| UUCP: {ddsw1 | olgb1 | olnl1} !olsa99!mje \_=_/ mje@olsa99.UUCP (mje@olsa99.uunet) #define DISCLAMER