Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!apple!rutgers!att!mcdchg!ddsw1!olsa99!mje From: mje@olsa99.UUCP (Mark J Elkins) Newsgroups: comp.unix.questions Subject: Re: Prompt for ksh Message-ID: <85@olsa99.UUCP> Date: 29 Oct 89 12:07:58 GMT References: <3028@jhunix.HCF.JHU.EDU> Organization: Olivetti Africa Lines: 81 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