zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: print color escapes
Date: Thu, 01 Jan 2015 11:24:21 -0800	[thread overview]
Message-ID: <54A59EE5.7000601@eastlink.ca> (raw)
In-Reply-To: <141231223506.ZM26289@torch.brasslantern.com>

On 12/31/2014 10:35 PM, Bart Schaefer wrote:
> torch% print -r ${(V)fg[cyan]}
> ^[[36m
> torch% print -r ${(q)fg[cyan]}
> $'\033'\[36m
Thanks, either is usable.

} I'd expect 'print } -r' to 'stay literal' with the expanded variable 
but no luck.

 > It is staying literal with the expanded variable. The variable has a 
literal escape (ascii 033) in the value, not the string backslash e, so 
print -r emits that literal escape etc. It's the terminal that then 
turns that into a color, not the print command.

Ok, we hafta stop the terminal from doing it's thing when we want to 
'see' the escape code without the terminal 'doing' the escape code. But 
why/where is the change made?  I tried this script:

    cyan='\e[36;1m'
    norm='\e[0m'
    print    "1: $fg[cyan] howdy $norm"
    print    "2: $cyan howdy $norm"
    print -r "7: the value of fg[cyan] is: ${(V)fg[cyan]}"
    print -r "8: the value of cyan       is: ${(V)cyan}"


    1:  howdy << nicely cyan
    2:  howdy << nicely cyan
    7: the value of fg[cyan] is: ^[[36;1m      << modified to 'bold' by me.
    8: the value of cyan       is: \e[36;1m

... either the " \e[ " or the " ^[[ " form produces the color change, so 
why does the 'color' function 'bother' to change from one form to the 
other, and how/where?  I see the escape created like this:

     local lc=$'\e[' rc=m

... so how does it end up like: " ^[[ " ?

BTW I know you can't type " ^[[ " and have it work, the " ^[ " 
represents the escape code but can't create it, so I know it's a 'safe' 
way of showing the code, but since both my '$cyan' and 'fg[cyan]' seem 
to work the same way,  I'm confused as to what the point of the 
difference is.


  reply	other threads:[~2015-01-01 19:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-01  5:47 Ray Andrews
2015-01-01  6:35 ` Bart Schaefer
2015-01-01 19:24   ` Ray Andrews [this message]
2015-01-01 21:29     ` Bart Schaefer
2015-01-01 23:02       ` Ray Andrews
2015-01-01 23:26         ` Bart Schaefer
2015-01-02  2:30           ` Ray Andrews
2015-01-02  2:45             ` Kurtis Rader
2015-01-02  3:50               ` Ray Andrews
2015-01-02  4:18                 ` Bart Schaefer
2015-01-02 17:43                   ` Ray Andrews
2015-01-02  1:21         ` Kurtis Rader
2015-01-02  2:39           ` Ray Andrews
2015-01-02  2:58             ` Kurtis Rader
2015-01-02  3:48               ` Ray Andrews

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=54A59EE5.7000601@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@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).