Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!sci.ccny.cuny.edu!phri!marob!betz From: betz@marob.uucp (Tom Betz) Newsgroups: comp.unix.xenix.sco Subject: Re: whoami? Summary: Here it is in ksh Message-ID: <277FBC44.310C@marob.uucp> Date: 31 Dec 90 22:31:32 GMT References: <6537@crash.cts.com> <18865@rpp386.cactus.org> Organization: Greyston Business Services Lines: 42 Quoth jfh@rpp386.cactus.org (John F Haugh II) in <18865@rpp386.cactus.org>: |From: article <6537@crash.cts.com> : |>What I want is something similiar to the BSD/SunOS whoami. For example, in a |>.cshrc file, I want to be able to do this: |> |>if (`whoami` == "root") then |> set prompt = "#" |>else |> set prompt = "%" |>endif |> | |Try something like this - | |% id | sed -e 's/^[^(]*(\([^)]*\)).*$/\1/' |jfh | |which would give you - | |if ( `id | sed -e 's/^[^(]*(\([^)]*\)).*$/\1/'` == "root" ) then | set prompt = "#" |else FWIW, Here's the ksh version, removed from my .kshrc: MYPROMPT="" if /bin/id | /bin/grep "uid=0" > /dev/null then MYPROMPT="#" fi MYPROMPT=${MYPROMPT}`/bin/tty | /usr/bin/cut -c9,10` PS1='$MYPROMPT ! $PWD> ' export PS1 This has the added benefit of displaying the current tty# and ksh history counter, as well as the cwd and a different symbol for root or non-root user. -- -------------- "Healt ut industri di go hond-e-hond." Tom Betz | ----------------------------------------------------------------- 914-375-1510 | marob!upaya!tbetz@phri.nyu.edu betz@marob.uucp%phri.nyu.edu GBS | {att,philabs,rutgers,cmcl2}!phri!marob!upaya!tbetz