Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

trick: up-to-the-minute time in prompt



here's a neat trick i just figured out... have the time that's displayed 
in your prompt update itself!

below is a sample with the first PS1 comented out... that would *just* 
display the time. the second example is a little more powerful...


## run TRAPALRM every $TMOUT seconds
TMOUT=30

TRAPALRM () {
     ## reset-prompt - this will update the prompt
     zle reset-prompt
}

## this PS1 will use "%T" to display the current time,
## updated every $TMOUT seconds
## example of prompt-expansion
#PS1='%S%T %#%s '


## this PS1 will use the `uptime` command to display system stats,
## updated every $TMOUT seconds
## example of prompt command substitution
setopt PROMPT_SUBST
PS1='%S$(uptime)
%#%s '




-- 
         ...atom

  ________________________
  http://atom.smasher.org/
  762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
  -------------------------------------------------

 	"These numbers have nothing to do with the technology of
 	 the devices; they are the maximum that thermodynamics will
 	 allow. and they strongly imply that brute-force attacks
 	 against 256-bit keys will be infeasible until computers
 	 are built from something other than matter and occupy
 	 something other than space."
 		-- Bruce Schneier, Applied Cryptography




Messages sorted by: Reverse Date, Date, Thread, Author