zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: Re: exclude users in watch variable?
Date: Wed, 11 Feb 2015 16:56:18 +0000	[thread overview]
Message-ID: <20150211165618.GA5230@tarsus.local2> (raw)
In-Reply-To: <20150211114654.GA22015@spiegl.de>

Andy Spiegl wrote on Wed, Feb 11, 2015 at 12:46:55 +0100:
> > For an alternative I'd suggest writing a custom precmd.
> Thanks for the suggestion.  I started to think about how to implement
> this but came to the conclusion that my zsh knowledge is not good
> enough for this. :-(  I could write a perl script but in precmd ... No!
> 
> Could one of you zsh cracks give me a good start, please?
> 

Like this? ---

    autoload -Uz add-zsh-hook
    old=
    precmd_who() {
      local new="$(who)"$'\n' # add newline to reduce spurious diffs
      if [[ -n $old ]] ; then diff =(<<<$old) =(<<<$new) ; fi
      old=$new
    }
    add-zsh-hook precmd precmd_who

If 'who' doesn't run quickly in your environment you'll notice delays
before shell prompts are drawn.  The variable 'old' is in the global
namespace, you should probably name it something more unique to avoid
name collisions.

Daniel


  reply	other threads:[~2015-02-11 17:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-04 17:46 Andy Spiegl
2015-02-10 19:28 ` Andy Spiegl
2015-02-10 21:45   ` Daniel Shahaf
2015-02-11 11:46     ` Andy Spiegl
2015-02-11 16:56       ` Daniel Shahaf [this message]
2015-02-12  5:22         ` Bart Schaefer
2015-02-11 12:26 ` Peter Stephenson
2015-02-11 15:16   ` Andy Spiegl

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=20150211165618.GA5230@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-users@zsh.org \
    /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).