bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: want prompt escapes outside prompt context


From: Francis Montagnac
Subject: Re: want prompt escapes outside prompt context
Date: 25 Jan 2002 18:05:54 GMT

In article <200201242057.g0OKv9e7020029@stay.intouchsys.com>,
 gildea@stop.mail-abuse.org (Stephen Gildea) writes:

>Bash 2.05 has all these great escapes for computing useful info and
>putting it in the prompt.  I would like to have access to this same
>information when I'm not just displaying a prompt.

That would be nice yes.

You can turn around that in your date_in_prompt by using the SECONDS
variable.

Something like:

init_prompt() {
  set -- $(date +'%k %M %S')
  start_sec=$(($1*3600+$2*60+$3))
  day=-1
}

init_prompt

prompt_basic='\t\$ '

date_in_prompt() {
  PS1=$prompt_basic
  local new_day=$(( (SECONDS+start_sec)/86400 ))
  if (( new_day > day )); then
    day=$new_day
    PS1="\d\n$PS1"
  fi
}

-- 
Francis.Montagnac@sophia.inria.fr, Tel: (33) 04 92 38 79 11, Bur: E106
INRIA Sophia, 2004, rte des Lucioles, B.P.93 - 06902 Sophia Antipolis Cedex



reply via email to

[Prev in Thread] Current Thread [Next in Thread]