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

Re: how to make colour prompts for pdksh



On Tue, 2006-07-25 at 19:48 +0200, LeVA wrote:
...
> This is working, so I started from there. I've added the colour codes, 
> but pdksh doesn't handle them.
> 
> C'mon, I can't beleive that nobody is using the korn shell :)

This is not a tutorial or anything and most of this can be found
googling, but this is my prompt:
PS1='^[]0;$USER@${HOST} ${PWD##*/}^G^M^[[0;32m[$USER@${HOST} ${PWD##*/}]$^[[m '

Note that the ^[ and ^G in the prompt string are single characters for
ESC and BEL (can be entered in emacs using C-q ESC and C-q C-g).  The
^M is a carriage return (C-q C-m in emacs), and needs to be used after
other escape characters in the prompt, so ksh can determine the screen
width properly.  I couldn't figure out a way to enter these control
characters with vi, but I didn't try too terribly hard either.  The
${PWD##*/} is a ksh construct to get the basename of the directory you
are in.

This part sets the title: 
^[]0;$USER@${HOST} ${PWD##*/}^G^M

This part set the prompt (with color): 
^[[0;32m[$USER@${HOST} ${PWD##*/}]$^[[m 


So a no frills color prompt without the title might be:
PS1='^[[0;32m[$USER@${HOST} ${PWD##*/}]$^[[m '

Jamie Strandboge

-- 
Anemone Computing
http://www.anemonecomputing.com/



Reply to: