Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!motcsd!hpda!hpcuhb!hpcllla!hpclisp!hpcljws!jws From: jws@hpcljws.HP.COM (John Stafford) Newsgroups: comp.unix.questions Subject: Re: Re: Time in prompt? Message-ID: <720009@hpcljws.HP.COM> Date: 15 Jun 89 20:19:24 GMT References: <1106@ucrmath.UCR.EDU> Organization: Hewlett-Packard Calif. Language Lab Lines: 27 Well in ksh you can get updated time, there is an example in the book that does hours and minutes. Here is mine that adds seconds as well (I don't claim it is the best way, I never have sorted out the weird subscript stuff). It should of course be . invoked or in your .profile or ENV file. # # Set up so we can use a clock in our prompt # export SECONDS="$(date '+3600*%H+60*%M+%S')" typeset -Z2 _h _m _s _hh="(SECONDS/3600)%24" _mm="(SECONDS/60)%60" _ss="SECONDS%60" _time='${_x[(_m=_mm)==(_h=_hh)+(_s=_ss)]}$_h:$_m:$_s' # # Change working directory and show the basename of the current working # directory and the current time in the prompt. # function wd { \cd $1 working="${PWD##*/}" PS1="${working:-/} $_time > " } alias cd=wd