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

Re: showing 'talk' status in PROMPT

> I am using this to let me know if I have turned off messages on my terminal:
> mesg () {
> }
> Does anyone see any problems with this, or have a better way to do this?

I do this by rather a different way.  Every so often, I check the status
of my TTY to see whether it has write access granted to others.  I
figure that I don't type 'mesg' very often, so checking every minute or
so isn't much of a performance loss.

I wanted to be able to just do something like 'mesg >/dev/null' to use
the exit status of mesg to determing if messages are on or not without
cluttering up my screen with "is n" or "is y".  But the writers of mesg
on Ultrix in all their wisdom, printed the message to stderr, and also
used stderr as the tty to check.  So it just couldn't work.

I finally wrote a tiny perl script to do it:

# Return y or n based on whether others can write to our tty.
# usage: mesg-status $TTY
if ((stat($ARGV[0]))[2] & 022)
  print "y\n";
  print "n\n";

so I just invoke this every now and again and insert it into my prompt
in the usual ways.

Granted, it isn't as efficient as the rewriting of the mesg function,
but I suppose it makes up for that by always being correct, if, say,
something else tries to change the status of my tty.

Debbie Pickett  http://www.cs.monash.edu.au/~debbiep/  tlm@xxxxxxxxxxxxxxxxxxxxx
"Long and wide, eternity from side to side, lead me through the rapids, guide me
 to the shore. There's a place that's far beyond this time and space, when each
  of us comes face to face with something more." - _Siren Song_, Alan Parsons

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