zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: "Johan Sundström" <johsu650@student.liu.se>, zsh-users@math.gatech.edu
Subject: Re: Emulating tcsh:s prompt
Date: Tue, 9 Jun 1998 15:15:33 -0700	[thread overview]
Message-ID: <980609151533.ZM7488@candle.brasslantern.com> (raw)
In-Reply-To: <005e01bd93e8$4da50cc0$cde8ec82@a205.ryd.student.liu.se>

On Jun 9, 10:50pm, =?iso-8859-1?Q?Johan_Sundstr=F6m?= wrote:
> Subject: Emulating tcsh:s prompt
> I'm trying to emulate tcsh:s cool prompt parameter %T in zsh using the
> precmd function. Tcsh:s version of %T gives a five character long field in
> the format HH:MM, with a slight exception; if the prompt is displayed on a
> full hour (MM=00), the text changes to "Ding!".

PS1="%(t.Ding\!.%D{%I:%M})> "

> ... the second time [that minute] a common HH:MM is generated.

Hardly seems worth the effort, but

precmd() {
  thisminute=$(print -P %D{%M})
  [[ $thisminute = ${lastminute:-0} ]] && {
	PS1="%D{%I:%M}> " ||
	PS1="%(t.Ding\!.%D{%I:%M})> " }
  lastminute=$thisminute
}

> I was wondering, whether there is any way I can set an environment variable
> in the parent shell from this function.

Any variable you set in a function is set in the "parent" shell.  Functions
run in the same context as builtins, by definition.

> I had hoped "exec export Hour=$HH" would do the job, but it didn't.

Leave off the "exec".


      reply	other threads:[~1998-06-09 22:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-09 20:50 Johan Sundström
1998-06-09 22:15 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=980609151533.ZM7488@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=johsu650@student.liu.se \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).