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

Re: how to make colour prompts for pdksh



2006. July 26. 16:35, James Strandboge:
> On Wed, 2006-07-26 at 15:42 +0200, LeVA wrote:
> > 2006. July 26. 14:32, James Strandboge:
> > > On Tue, 2006-07-25 at 22:59 +0200, LeVA wrote:
> > > Are you *sure* that the control characters have been entered
> > > correctly? It is not '^' followed by '['.  It must be the single
> > > charactor '^['.
> >
> > 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.
>
> ...
>
> > When I'm using a login shell, everything is working.
> > But when I'm using a non-login shell (in my case Konsole from KDE),
> > then everything gets still sourced from my ~/.profile (so my PS1 is
> > 'whatever...') *BUT* the aliases are not working.
>
> It needs to be a login shell, or have ENV set.  From the man page:
>        If the basename of the name the shell is called  with  (i.e., 
> argv[0]) starts with - or if the -l option is used, the shell is
> assumed to be a login shell and the shell reads and executes the
> contents of  /etc/pro‐ file and $HOME/.profile if they exist and are
> readable.
>
>        If  the  ENV parameter is set when the shell starts (or, in
> the case of login shells, after any profiles are processed), its
> value is subjected to  parameter,  command,  arithmetic  and  tilde 
> substitution  and the resulting file (if any) is read and executed. 
> If ENV parameter is  not set  (and  not  null) and pdksh was compiled
> with the DEFAULT_ENV macro defined, the file named in that macro is
> included (after the above men‐ tioned substitutions have been
> performed).
>
> So either set konsole up to launch ksh as a login shell, or set ENV
> somewhere.  You can test this with:
>
> $ ENV="~/.profile" konsole
>
> Or launch konsole, and do:
> $ ksh -l
The .profile is always gets parsed (both in a login and a non-login 
shell). I can only set the ENV parameter in the .profile, because it is 
the first and only file which is used by pdksh when it starts. But 
setting the ENV parameter in the .profile file doesn't make any sense 
if I have a file (the .profile) which have already been parsed by 
pdksh. I can put all my variables and aliases etc... in to my .profile, 
and no need for another startup file.
But, I can see the ENV variable's meaning in another context, please 
read along.
When I start pdksh in a non-login shell, the .profile gets parsed, and 
the PATH and every other env.var. gets set. Only the aliases gets 
ignored, but why? Pdksh parses the alias commands too, why don't they 
appear in a non-login shell, and why do they appear in a login shell?
The .profile file is the same...

If I add the ENV="~/.kshrc" line to my .profile and my ~/.kshrc contains 
my aliases, then I still can not see my aliases... And that is what 
I've expected, beacuse only by sourcing another file from an already 
parsed file doesn't make it working...
If I start konsole with 'ENV="~/.kshrc" konsole' then my aliases are 
working. So this is solution no.1.

> If you setup .profile the way I suggested (eg, by setting ENV to
> be .kshrc), konsole works properly.
Unfortunatelly not. The solution which is working is the konsole 
starting method that you've suggested.

The man says that "if the ENV parameter is set when the shell starts" :)
This is funny because I can set the ENV parameter in a shell, and I can 
not set it before running the shell :) Something must be running 
already (eg. KDE) to be able to set up the variable. I can put a file 
which contains 'ENV="~/.kshrc"' to my ~/.kde/env/ and that gets sourced 
by kde startup, so the ENV parameter will be set when I start konsole. 
Wait a minute... that is what I'm gonna do! :)

Daniel

-- 
LeVA



Reply to: