[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to make colour prompts for pdksh



On Wed, Jul 26, 2006 at 04:55:02PM +0200, Florian Kulzer wrote:
> > > Now that your pointing this out for me :) indeed I was using a
> > > '^' char followed by a '['.  But how can I enter that control
> > > character? What is the keycombo for it?
> > 
> > Check my previous email.  I don't know how to do it in vi
> > (unfortunately), but it can be done in emacs.
> 
> With vi, when you are in edit mode ("-- INSERT --" etc.), you can press
> <CTRL> + Q followed by <ESC>. (Release the other two keys again before
> you press <ESC>.) If you use colors you will see that '^[' is shown in a
> different color to indicate that it is a special character and not just
> '^' + '['. It is furthermore treated as one character when you move the
> cursor across it.

If I may be pedantic...  First of all you mean vim.  The original vi
does not support syntax coloring, and there are other vi clones which
may behave differently than you describe (like elvis, etc.).

Secondly, the key to use is dependent on your operating system and
terminal settings.  On Windows, the key seems to be CTRL-Q.  On
virtually any Unix platform, the default is CTRL-V but is configurable
by the user, using stty or similar terminal control programs.  The
setting is controlled by your terminal, not by vim per se.

You can see what it is currently set to using stty -a:

  $ stty -a
  speed 38400 baud; rows 24; columns 80; line = 0;
  intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
  eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
  lnext = ^V; flush = ^O; min = 1; time = 0;
  -parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
  -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
  -iuclc -ixany -imaxbel
  opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
  isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
  echoctl echoke

Notice on the 4th line of output at the beginning, the entry 

  lnext = ^V

This is the key which is correct on your terminal.  The "lnext"
keyword is short for "literal next character" and is what you would
use to change the key using stty.  For example:

  stty lnext ^U

...changes the character to CTRL-U, though this isn't recommended as
^U normally corresponds to the kill character (not the same as the
kill command) by default.  These are the normal defaults for xterm and
its cousins, which are based on the DEC vt100 family of terminals, as
is the Linux console.  Note from the output above that ^Q is assigned
to "start" which is the XON character for terminal flow control, so it
will not work as advertised above on this terminal.

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D

Attachment: pgppQNviVSXi2.pgp
Description: PGP signature


Reply to: