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

Re: how to make colour prompts for pdksh



2006. July 25. 21:20, James Strandboge:
> 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 '
>
Thanks a lot for the reply, I've tried it and it stays the same :\ just 
spits out the characters, and no colours.
I've tried it with ksh (the original, not the public domain) and it is 
working as expected. So it seems to me that pdksh is broken; or not... 
I don't know. I thought that pdksh wants to "clone" ksh88 and ksh93. 
This rewrite indeed implements some features from ksh88 and some from 
ksh93, but surely not all, and some of them are broken. The 
maintainer's latest version dates back to '99 and I just saw the 
existing bugs' page... I could've passed over this colour trouble, but 
the alias exporting is not working which I surely need.
As I don't want to use the original ksh (although it is working :) I 
guess I'm just stuck with the good old bash, and use pdksh on my bsds.

Thanks for your efforts, and help.

Daniel

-- 
LeVA



Reply to: