Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Colored PS1

On Sep 8,  5:31am, Meino Christian Cramer wrote:
} > "escape sequence" in the context of terminals means "a series of ASCII
} > characters, often beginning with the ESC (\033, \x1B) character."  It
} > is common for terminals and terminal emulators to recognize such a
} > series of characters in the output and alter the terminal's behavior.
}   ...oh I see...something like "commands"! :)

Yes, except that the "commands" are embedded in the same stream as the
ordinary non-command data.  It's more like a very crude form of markup.
In HTML, you'd write
    I am not bold but <bold>I am brave!</bold>
and in "terminal markup" you'd write
    I am not bold but ^[[01;39mI am brave!^[[00m
(where ^[ is the ESC character).  In neither case do you see the markup
when the text is displayed (hence, no cursor movement).

} > The trouble is that "escape sequnce" in the context of a prompt means
} > one of the pairs of characters that begins with a percent (%) sign.
} > Again this is from the concept of a special combination of characters
} > causing a change (an escape from) the usual interpretation of such
} > characters.
} >
} ...do I understand this cxorrectly? In other words:
}   The trouble is, that a escape seuence can be misinterpreted as a
} special sign of the prompt expanding itsself ?

No, nothing like that.  I'm only talking about humans misunderstanding
the confusing terminology, not zsh misinterpreting the strings.  Look
at what I was just saying about markup ... prompts have "markup" too:

    I am not bold but %BI am brave!%b

Prompt markup can't change colors, though, so sometimes you have to mix
terminal markup and prompt markup.  The prompt markup %{ and %} tell zsh
that what's in between is some other kind of markup, so that it should
not count it as something that occupies space on the display.

} > In the worst case, you go look at the documentation for an ANSI standard
} > terminal
} > the definition whether any cursor movement is involved.
}   URKS!

Yeah, but that's why I said "in the worst case."

} Setting PS1 directly without the addtional step using $prompt it does
} not work.

That makes no sense at all.  Something is happening that you don't know
how to tell us, and I don't know what to ask to learn what it is.

However ...

} I am happy haveing a colored prompt

... if you're happy, we don't need to pursue it any further right now.

} ... only wihing that sometimes
} zshall would be more understandable than totally complete.

Wishing?  Buy Oliver and Peter's book!

Messages sorted by: Reverse Date, Date, Thread, Author