zsh-workers
 help / color / mirror / code / Atom feed
From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh-workers@zsh.org
Cc: idl0r.qasl.de@bones.voodoo.lan
Subject: Escape characters in $psvar[]
Date: Fri, 19 Nov 2010 14:04:35 +0100	[thread overview]
Message-ID: <871v6h79cs.fsf@ft.bewatermyfriend.org> (raw)

Hey list,

The following came up on IRC.

A user uses the `clint' prompt, which uses `psvar' to include results
from `vcs_info'. He wanted to include colour codes in the vcs_info
formats for proper eye candy. Which resulted in literal "^[[35m" strings
in the actual prompt instead of colours.

It seems using $psvar[] replaces escape characters (ascii 0x1b) with two
characters: `^' and `[':

[snip]
% autoload -Uz colors
% colors
% psvar[9]=$fg[red]foo
% print ${psvar[9]} | hd -c
00000000  1b 5b 33 31 6d 66 6f 6f  0a                       |.[31mfoo.|
0000000 033   [   3   1   m   f   o   o  \n                            
0000009
% print -P '%9v' | hd -c
00000000  5e 5b 5b 33 31 6d 66 6f  6f 0a                    |^[[31mfoo.|
0000000   ^   [   [   3   1   m   f   o   o  \n                        
000000a
[snap]

Is that indented behaviour or a bug? A quick skim through the docs
didn't turn up an answer.

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


             reply	other threads:[~2010-11-19 13:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-19 13:04 Frank Terbeck [this message]
2010-11-19 14:03 ` Peter Stephenson
2010-11-19 14:06   ` Peter Stephenson

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=871v6h79cs.fsf@ft.bewatermyfriend.org \
    --to=ft@bewatermyfriend.org \
    --cc=idl0r.qasl.de@bones.voodoo.lan \
    --cc=zsh-workers@zsh.org \
    /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).