*BSD News Article 53366


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!newshost.telstra.net!kettle.magna.com.au!news.cs.su.oz.au!harbinger.cc.monash.edu.au!msunews!agate!howland.reston.ans.net!newsfeed.internetmci.com!news.sprintlink.net!psgrain!iafrica.com!ticsa.com!cstatd.cstat.co.za!ee.und.ac.za!wabe.csir.co.za!zibbi!jtonsing
From: jtonsing@zibbi.mikom.csir.co.za (Johann Tonsing)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: DOS Style shell prompt
Date: 20 Oct 1995 21:21:14 GMT
Organization: CSIR - Council for Scientific and Industrial Research
Lines: 55
Message-ID: <4693sb$6it@wabe.csir.co.za>
References: <814126352.7670@kiss.demon.co.uk> <4675hg$t7p@news.bu.edu>
NNTP-Posting-Host: zibbi.mikom.csir.co.za
X-Newsreader: TIN [version 1.2 PL2]

Mikhail Teterin (mi@bu.edu) wrote:
: Some time ago (Thu, 19 Oct 1995 18:11:16 GMT) honorable Phil Taylor, 
: residing at phil@zipmail.co.uk wrote:

: |This is very usefull (unless you have gone very deep in the directory
: |structure) and saves a pwd every time you do an rm -r * . It helps
: |just to check where you are. I know people that have accidently  done
: |rm -r * in /  because they were logged in as root on an SCO system and
: |had typed cd on its own just before !!!!! (best thing to do with SCO
: |anyway 8-).

: This are my settings (for tcsh, for csh, you'll have to change a bit),
: if anyone can suggest something better -- please! This is ugly :-) :
: 	alias setprompt 'set prompt="%m:${PWD}\(\!\) "'
: 	alias cd        "chdir \!* && setprompt"
: 	alias ppd       "popd \!* && setprompt"
: 	alias psd       "pushd \!* && setprompt"

: %m stays for machine name (in csh -- run hostname first, then make an 
: alias),
: ! will make it print the sequentinal number of the command.
: --
: 		hot-dog  apple-pie  baseball  Chevrolet

For tcsh one does not need to set the prompt variable every time.
Here is "code" that works for both csh and tcsh:

if ($?prompt && $?TERM) then
  if ($?tcsh) then
# ...put bindkey commands for tcsh here...  
    if ($TERM == xterm || $TERM == xterms || $TERM == xterml) then
      set prompt="%{\e]2\;%n@%m %l %~%#^g\e]1\;%n@%m^g\r%}%~%# "
    else
      set prompt="%n@%m:%~%#%L "
    endif
  else
    alias pushd 'pushd \!*; set prompt="${HOSTNAME}:$cwd> "'
    alias popd 'popd; set prompt="${HOSTNAME}:$cwd> "'
    alias cd 'cd \!*; set prompt = "${USER}@${HOSTNAME}:$cwd> "'
    set prompt = "${USER}@${HOSTNAME}:$cwd> "
  endif
endif

This will also set the window title and icon title to useful info if in an
xterm. For tcsh, the prompt will be "...# " if you are root and "...> " if
you are another user.

man tcsh for info on the % options.

Have fun changing this!  
Johann

--
jtonsing@mikom.csir.co.za, Fax: Int+27 12 841-4570,
S-mail: 173 Duxbury Rd, Hillcrest, 0083 Pretoria, South Africa.