From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24413 invoked by alias); 25 Mar 2013 19:40:23 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17739 Received: (qmail 6539 invoked from network); 25 Mar 2013 19:40:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.214.53 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=Jod+WDjcRmhFlEx6vPixGcXGLJdUGzgeX9OAew7MY4Y=; b=s2pAyfOIdwTPGG0NqJHhdaZXF+5zzl0137i+iVhLcowmcDkBQ/prG1+lnGHDA0z62o XEzrc0yFJLN96IyiNMXDUroD0vIxsDJKPoQXwReb9JMxHWrPQNU2E2rEa7KlbaXP/SY+ 2PRZGBdf23BXdEfEiLlJAr8VX4kxY1N26gOxq+SbIY94eHbJjRAH2ljhCD5kU0t1MEii iu3S76ilAUKPdj8bwnHmL50ApBhCEpyoD0GH8o4+H7fSaEDiFxvnaPX9cr3JhGk1Ucbl rcKWyVTEGYY8ce9VDEoryxMZyVNokyjEKbwTXHE1Ftdhg0oqfJT23Hl4k6vREGk9jgtz yReg== X-Received: by 10.204.244.135 with SMTP id lq7mr6272947bkb.138.1364240404529; Mon, 25 Mar 2013 12:40:04 -0700 (PDT) Date: Mon, 25 Mar 2013 20:40:00 +0100 From: seanh To: zsh-users@zsh.org Subject: Re: Outputting colored zsh prompts from an external script Message-ID: <20130325194000.GA27762@kaeru> References: <20130324192345.GA20437@kaeru> <871ub431wq.fsf@gmail.com> <130325082938.ZM24580@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <130325082938.ZM24580@torch.brasslantern.com> User-Agent: Mutt/1.5.21 (2010-09-15) > > So far this color issue is the only thing getting in my way... > > Your python script needs to either output %F{color} / %K{color} instead > of the raw ANSI sequences, or (might be easier) put %{ and %} around the > ANSI. Both methods tell zsh that this output is "zero-width" on the > terminal, so it doesn't count those bytes when determing how much screen > space the prompt uses. See also %G in the manual. That was exactly what I needed, thanks! Took all of two seconds to apply and worked perfectly. I've updated the gist. The Python code could be written more clearly, to make it explicit that the ANSI codes are getting wrapped in zsh zero-width codes. Once I've given it some testing and finished it off, I'll publish the script properly somewhere.