zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Timothy Luoma <lists@tntluoma.com>
Cc: zsh-users@sunsite.dk
Subject: Re: can zsh set background color?
Date: Tue, 4 Jan 2005 08:55:12 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.61.0501040742220.14094@toltec.zanshin.com> (raw)
In-Reply-To: <D4174DD1-5E63-11D9-B4A6-000D93AD26C8@tntluoma.com>

On Tue, 4 Jan 2005, Timothy Luoma wrote:

> Is there any way for zsh to set the background color of my terminal 
> program?

Depends on what the program is, but probably not.  From the shell you can 
set the attributes of the text that is displayed (which is what MMJ is 
getting at in his reply) but not the color of the entire terminal.

> I'm often logged into to 3 different computers (ssh), and it would be 
> handy to be able to quickly look for the color of one to know that it 
> was the one where I was connected to X

[I wrote everything that follows while thinking "connected to X" meant 
"connected using an X11 terminal emulator", but now I think it means "to 
the host named X" so this may all be irrelevant.  Having written it down,
though, I'm going to send it anyway.]

This is really an X11 question, and it depends on how you run your 
terminal emulators, but I'll do my best to turn it into a zsh question
anyway.  Let's assume xterm for discussion.

If you run xterm locally and invoke the remote login from xterm, then you
have to do something like this:

---- 8< ----
typeset -A xterm_colors
xterm_colors=( host1 red
               host2 blue
               host3 green )
function xterm {
  setopt localoptions extendedglob noksharrays nokshglob

  # Fast crude command line parsing here, could be better
  if [[ " $*" = [[:space:]]-(fg|foreground) ]]
  then
    command xterm "$@"
  else
    local rshell='(ssh|rlogin|telnet)'
    local userpat='(|*@|-l[[:space:]][^[:space:]]#[[:space:]])'
    local remotepat="* -e ${rshell} ${userpat}(#b)([^[:space:]@]#)*"

    local color=white
    if [[ " $*" = ${~remotepat} && -n "${xterm_colors[${match[1]}]}" ]]
    then
      color=${xterm_colors[${match[1]}]}
    fi
    command xterm -fg $color "$@"
  fi
}
---- 8< ----

However, if you instead run "xon host xterm ..." or the equivalent, then
you can just put an appropriate X resource file, e.g. one named XTerm, in 
your home directory on the remote machine, and set the foreground color in
that file.

(Unless you have the same NFS-mounted home directory everywhere, in which
case you're back to the first plan.)


  parent reply	other threads:[~2005-01-04 16:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-04 15:18 Timothy Luoma
2005-01-04 15:20 ` Mads Martin Joergensen
2005-01-04 17:12   ` Timothy Luoma
2005-01-06  1:46     ` lists
2005-01-07 23:14       ` Timothy Luoma
2005-01-12  7:43         ` Juhapekka Tolvanen
2005-01-12 10:18           ` David Gómez
2005-01-04 16:55 ` Bart Schaefer [this message]
2005-01-04 17:04   ` Timothy Luoma
2005-01-05  3:50 ` Drew Perttula
2005-01-05  9:29   ` Bart Schaefer

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=Pine.LNX.4.61.0501040742220.14094@toltec.zanshin.com \
    --to=schaefer@brasslantern.com \
    --cc=lists@tntluoma.com \
    --cc=zsh-users@sunsite.dk \
    /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).