From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12052 invoked from network); 4 Jan 2005 16:55:36 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 4 Jan 2005 16:55:36 -0000 Received: (qmail 9385 invoked from network); 4 Jan 2005 16:55:30 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Jan 2005 16:55:30 -0000 Received: (qmail 23670 invoked by alias); 4 Jan 2005 16:55:19 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8323 Received: (qmail 23658 invoked from network); 4 Jan 2005 16:55:18 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 4 Jan 2005 16:55:18 -0000 Received: (qmail 8325 invoked from network); 4 Jan 2005 16:55:18 -0000 Received: from moonbase.zanshin.com (64.84.47.139) by a.mx.sunsite.dk with SMTP; 4 Jan 2005 16:55:14 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.13.1/8.13.1) with ESMTP id j04GtCnS001394; Tue, 4 Jan 2005 08:55:12 -0800 Date: Tue, 4 Jan 2005 08:55:12 -0800 (PST) From: Bart Schaefer Reply-To: zsh-users@sunsite.dk To: Timothy Luoma cc: zsh-users@sunsite.dk Subject: Re: can zsh set background color? In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 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.)