Mail Archives: cygwin/2001/07/04/10:12:12
Sandeep,
You've got to realize that this is not the sole province of BASH. Its
manual documents fully its role, namely how the characters sequence is
expanded and how non-printing portions can be delimited so that the
readline functions know where the cursor is on the line.
All the rest is interpreted by the terminal emulator. For information on
what these strings do, you'll have to look elsewhere. I don't know where
that information resides, but I'm sure it can be found on the Internet.
The unescaped open bracket is just that. It is part of a multi-character
escape sequence (\033 is ESCape) defined by the terminal control mechanism
emulated by the Cygwin console code (layered over the Windows character
subsystem window) or the RXVT terminal emulator (something in the vt1xx or
vt2xx series, I guess). For example, ESC-[-32m and ESC-[-33m are two single
control sequences. I don't know what they do for sure, but judging from the
appearance of the resulting prompt, they change the color. (Since I like
dark background for character windows like shells, this is a very poor
choice for me, but that's neither here nor there.)
The \w, \u, \h, etc. are expanded by the shell. \007 is BEL (CTRL-G,
"beep"). \033 is ESC. If you look at my example, you must bear in mind
BASH's interpretation of string literals of the form $'...'.
Good luck.
Randall
At 22:26 2001-07-03, you wrote:
>I mis-spoke earlier. I didn't mean escape characters. I meant those \[
>sequences. Overall, my prompt problems (and probably problems of the
>person who originally complained about rxvt) was due to pilot error.
>Although to be honest, I still don't understand even after reading the
>PROMPTING section of the bash man page (which I did once a long time ago)
>how to interpret the default PS1 (which works) but which I changed since I
>hated it (I can't stand a prompt that takes up it's own line). And I
>changed it incorrectly. Here's the default:
>
>sandman AT BWELCH-W2k ~
>$ echo $PS1
>\[\033]0;\w\007 \033[32m\]\u@\h \[\033[33m\w\033[0m\] $
> ^ ^* ^ ^
>The man page for bash doesn't mention what un-backslashified [ or ] does
>in a prompt (indicated by the ^'s above). And what the heck's 32m
>(indicated by the *)? The bash man page never mentions how prompt color
>is changed, although I suspect the parts I've indicated above probably do
>that magic.
>
>Anyway, I did my own changes to the prompt to get rid of some of the
>things I didn't like, but I ended up getting some strange issues when I
>did Ctrl-a and Ctrl-e, as well as just using arrow keys. But it was
>definitely because I had not set PS1 100% correctly. But I don't think I
>ever will unless there's some information source that explains this stuff
>better than the bash man page. I mean, putting escape sequences in
>prompts is not bash-specific or Cygwin-specific. It's a very common thing
>in UNIX, and so I even tried searching through some man pages in my UNIX
>box. But sometimes man -k isn't good enough unless you know the proper
>terminology for what you're looking for.
>
>So basically, this whole rxvt thing prompted me to do what I should've
>done months ago for a number of other reasons (i.e. features in zsh that
>bash doesn't have) so it worked out for the best (for me at least; don't
>know about the guy who made the original post! ;) ) But I am curious:
>where does one find information on all these \[ sequences and what they do
>in a vt100 or vt220 or xterm terminal?
>
>-Sandeep
>
>Randall R Schulz wrote:
>
>>Hi,
>>Here's a little more on the promt business. It has proved popular with
>>fellow nerds in my office:
>>My PS1 for any terminal (emulator) that supports it (xterm, xterm-color,
>>vt100, vt102, vt220, cytwin, at least) is this:
>>
>>PS1=$'\[\e]0; \u :: \W (\w)\a\]\!> '
>># Note:
>># This sequence:
>># ESC]0;
>># ^ zero
>># Starts the title setting sequence. Everything from there to
>># the CTRL-G (also "\a" within $'...') is put in the window title.
>># Some terminal emulators (notably TeraTerm) put a pretty stingy
>># limit on how much they'll display, but you don't have to limit
>># the length you attempt to put there
>>
>>I don't mind the information typically put into prompts, but I _hate_ to
>>have it literally in the prompt!
>>Randall
>
>---------------------------------------------
>Sandeep
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -