From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18487 invoked from network); 17 Nov 2006 16:02:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 17 Nov 2006 16:02:29 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 28443 invoked from network); 17 Nov 2006 16:02:23 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 Nov 2006 16:02:23 -0000 Received: (qmail 2782 invoked by alias); 17 Nov 2006 16:02:11 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11002 Received: (qmail 2772 invoked from network); 17 Nov 2006 16:02:11 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 Nov 2006 16:02:11 -0000 Received: (qmail 26818 invoked from network); 17 Nov 2006 16:02:11 -0000 Received: from cavecanem.ucsc.edu (128.114.150.237) by a.mx.sunsite.dk with SMTP; 17 Nov 2006 16:02:07 -0000 Received: from cavecanem.ucsc.edu (localhost [127.0.0.1]) by cavecanem.ucsc.edu (8.13.6/8.13.5) with ESMTP id kAHG36ha002487 for ; Fri, 17 Nov 2006 08:03:06 -0800 (PST) Received: (from web@localhost) by cavecanem.ucsc.edu (8.13.6/8.13.1/Submit) id kAHG35Xo002486; Fri, 17 Nov 2006 08:03:05 -0800 (PST) X-Authentication-Warning: cavecanem.ucsc.edu: web set sender to wgscott@chemistry.ucsc.edu using -f Received: from 69.3.145.87 (SquirrelMail authenticated user wgscott) by mail.acg.ucsc.edu with HTTP; Fri, 17 Nov 2006 08:03:05 -0800 (PST) Message-ID: <34570.69.3.145.87.1163779385.squirrel@mail.acg.ucsc.edu> Date: Fri, 17 Nov 2006 08:03:05 -0800 (PST) Subject: [Fwd: Re: vi mode] From: "William Scott" To: zsh-users@sunsite.dk User-Agent: SquirrelMail/1.4.6 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal For the collective memory: On 11/17/06, William Scott wrote: > So what did Bart actually suggest? I'd like to do this too. I switched > to vi mode a couple of months ago and in general like it better, but > found that my brain had been hard-wired to do vi for editing and > emacs-bindings for shell interaction, so it is still slightly awkward. > What would be kind of cool is if the color of the prompt could change or > the title bar could change dynamically. > Getting the titlebar to change dynamically is a piece of cake. The color of the prompt isn't too hard, either. My desire for a text indicator that is somewhere other than the prompt proved to be nearly impossible, however. Bart suggested this, which would make the current mode appear on the far right of the screen as a right side prompt. function zle-line-init zle-keymap-select { RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}" RPS2=$RPS1 RPS3=$RPS1 RPS4=$RPS1 zle reset-prompt } zle -N zle-line-init On the other hand, if you'd like to just have your normal prompt change colors, the following should work, assuming that the first thing in your prompt string definition is a color escape insulated between '%{' and '%}'. For instance, mine is PS1=$'%{\e[34;1m%}%20>..>%1~%>>>%{\e[0m%}' Try something like this: function zle-keymap-select { PS1=${${1/vicmd/$'%{\e[31;1m%}'}/(viins|main)/$'%{\e[34;1m%}'}${PS1#*%\}} zle reset-prompt } where 31;1m is the color code that you want for normal mode (that's bright red) and 34;1m is the color code for insert mode (bright blue). If you have any more questions, you should probably direct them towards the zsh-users list, so other people can benefit from the answers. ~Matt