Re: .kshrc Definitions under X

2015-04-11 Thread Henrique Lengler
On Sat, Apr 11, 2015 at 10:24:47AM +0200, Eckehard Berns wrote:
> On Fri, Apr 10, 2015 at 09:03:26PM -0300, Henrique Lengler wrote:
> > > > > > On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> > > > > > > If you start X with xdm, then you need to either
> > > > > > > A) manually set ENV (or source your entire .profile) from your
> > > > > > > .xsession that xdm invokes, OR
> > > > > > > B) tell xterm to start the shell inside it as a login shell, so 
> > > > > > > that
> > > > > > > *that* will read your .profile.  This can be done by either:
> > > > > > >B1) start xterm with the -ls option, or
> > > > > > >B2) set "*loginShell: true" in your X resource database (c.f. 
> > > > > > > xrdb(1))
> > > [...]
> > 
> > I know that xterm isn't being started with -ls option and it solve thw
> > problem.
> > 
> > But this couldn't be normal, is it? Because my intention is not to use
> > only xterm but also others term. emulators like st, and I would like to have
> > they working as it does in any other system.
> > If this is normal, will I need to configure and make sure that every
> > term. emulator I'm using is loading .profile.
> 
> ksh is a bit special in the part that it won't read any startup
> file unless it is started as a login shell or it sees the ENV
> environment variable. (ksh has its reasons for this behavior.)
> 
> What I'm doing is a variant of option A above. I use .xinitrc as
> my main startup file for X. Since xdm starts .xsession instead I
> simply have the line
> 
> exec /bin/ksh -l ~/.xinitrc
> 
> in it. That telles ksh to run .xinitrc as a login shell and thus
> sources .profile first. That way ENV is set properly and every
> terminal should work as expected. Starting X with startx also is
> working properly since it inherits the ENV variable from my console
> login.

So it is working now. I don't know what was the problem.
It started to work today when I turned on my computer, this is strange.
I thought that only pressing Control-D until I logout and then login
again would apply and load new settings.

Now it is working and I have a normal setup:

$ cat .kshrc
alias ls='ls -p'
alias clr=clear
alias p='ps -l'
alias df='df -h'

$ cat .profile
export ENV=$HOME/.kshrc
export LC_CTYPE="en_US.UTF-8"
export GOPATH=$HOME/go
PATH=$PATH:$HOME/Scripts

And looks like there is no need to 'XTerm*loginShell: true' on
.Xdefaults.

I hope it will stay working.
-- 
Regards

Henrique Lengler 



Re: .kshrc Definitions under X

2015-04-11 Thread Eckehard Berns
On Fri, Apr 10, 2015 at 09:03:26PM -0300, Henrique Lengler wrote:
> > > > > On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> > > > > > If you start X with xdm, then you need to either
> > > > > > A) manually set ENV (or source your entire .profile) from your
> > > > > > .xsession that xdm invokes, OR
> > > > > > B) tell xterm to start the shell inside it as a login shell, so that
> > > > > > *that* will read your .profile.  This can be done by either:
> > > > > >B1) start xterm with the -ls option, or
> > > > > >B2) set "*loginShell: true" in your X resource database (c.f. 
> > > > > > xrdb(1))
> > [...]
> 
> I know that xterm isn't being started with -ls option and it solve thw
> problem.
> 
> But this couldn't be normal, is it? Because my intention is not to use
> only xterm but also others term. emulators like st, and I would like to have
> they working as it does in any other system.
> If this is normal, will I need to configure and make sure that every
> term. emulator I'm using is loading .profile.

ksh is a bit special in the part that it won't read any startup
file unless it is started as a login shell or it sees the ENV
environment variable. (ksh has its reasons for this behavior.)

What I'm doing is a variant of option A above. I use .xinitrc as
my main startup file for X. Since xdm starts .xsession instead I
simply have the line

exec /bin/ksh -l ~/.xinitrc

in it. That telles ksh to run .xinitrc as a login shell and thus
sources .profile first. That way ENV is set properly and every
terminal should work as expected. Starting X with startx also is
working properly since it inherits the ENV variable from my console
login.

-- 
Eckehard Berns



Re: .kshrc Definitions under X

2015-04-10 Thread dan mclaughlin
On Fri, 10 Apr 2015 20:48:39 -0400 John Merriam  wrote:
> On 4/10/2015 8:03 PM, Henrique Lengler wrote:
> > On Fri, Apr 10, 2015 at 07:51:01PM -0400, dan mclaughlin wrote:
> >> you should see an '-ls' option at the end as above. if not, that is your
> >> problem (it's not invoking a login shell), and this should work:
> >
> > I know that xterm isn't being started with -ls option and it solve thw
> > problem.
> >
> > But this couldn't be normal, is it? Because my intention is not to use
> > only xterm but also others term. emulators like st, and I would like to have
> > they working as it does in any other system.
> > If this is normal, will I need to configure and make sure that every
> > term. emulator I'm using is loading .profile.
> >
> >> On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> >>> B) tell xterm to start the shell inside it as a login shell, so that
> >>> *that* will read your .profile.  This can be done by either:
> >>> B1) start xterm with the -ls option, or
> >>> B2) set "*loginShell: true" in your X resource database (c.f. xrdb(1))
> >>
> >> also, xterm may be invoked elsewhere like in your ~/.xinitrc, so you would
> >> need to fix it there, but the xrdb option should take care of that.
> 
> See the -l option of ksh.  Also search for the word login in the ksh man 
> page.  ksh (and most if not all other shells I believe) behave 
> differently if they think they are a login shell.  xterm does not not 
> automatically tell the shell that is invoked when it starts that the 
> shell should be a login shell.  That is why the -ls xterm option exists.
> 
> It can be useful not to tell the shell invoked by xterm that it is a 
> login shell when you are running something in xterm besides an 
> interactive command prompt session.  See the xterm man page.  You can 
> run things in an xterm besides just a command prompt shell (shell 
> scripts, other text programs, etc.) in which case you wouldn't want 
> login shell type things being set up.
> 
> -- 
> 
> John Merriam
> 

as far as i can tell this is the openbsd default to do a login shell, and
it makes sense. for those other functions, which are for a more expert set
anyway, they probably can figure it out ('xterm -e').



Re: .kshrc Definitions under X

2015-04-10 Thread dan mclaughlin
sorry to Henrique for the duplicate.

On Fri, 10 Apr 2015 21:03:26 -0300 Henrique Lengler  
wrote:
> On Fri, Apr 10, 2015 at 07:51:01PM -0400, dan mclaughlin wrote:
> > On Fri, 10 Apr 2015 18:49:02 -0300 Henrique Lengler 
> >  wrote:
> > > On Fri, Apr 10, 2015 at 12:22:45AM -0400, dan mclaughlin wrote:
> > > > On Thu, 9 Apr 2015 16:58:29 -0300 Henrique Lengler 
> > > >  wrote:
> > > > > On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> > > > > > On Sun, Apr 5, 2015 at 9:12 PM, Andrew Fresh  
> > > > > > wrote:
> > > > > > > On Sun, Apr 05, 2015 at 10:50:47PM -0300, Henrique Lengler wrote:
> > > > > > >> And it is called in ~.profile with this:
> > > > > > >> . /home/henri/.kshrc
> > > > > > >>
> > > > > > >> The problem is that these definitions work out of X, in the 
> > > > > > >> console,
> > > > > > >> logged as the same user (henri) but don't work under X.
> > > > > > >> I open a xterm window and and type clr, I receive:
> > > > > > >> /bin/ksh: clr: not found
> > > > > > >> But out of X it works, can someone help me to make this thing 
> > > > > > >> work
> > > > > > >> normally?
> > > > > > >
> > > > > > >
> > > > > > > What I have done is set "ENV=$HOME/.kshrc" in .profile, then 
> > > > > > > whenever you
> > > > > > > open a new shell, it will use that file as a shell startup file.
> > > > > > 
> > > > > > That's step one, but whether it's enough depends on how you start X.
> > > > > > 
> > > > > > If you start X from the command line with 'startx' then yes, using
> > > > > > export ENV=$HOME/.kshrc in your .profile should be enough, because
> > > > > > your X clients will inherit that in the environment from startx.
> > > > > > 
> > > > > > If you start X with xdm, then you need to either
> > > > > > A) manually set ENV (or source your entire .profile) from your
> > > > > > .xsession that xdm invokes, OR
> > > > > > B) tell xterm to start the shell inside it as a login shell, so that
> > > > > > *that* will read your .profile.  This can be done by either:
> > > > > >B1) start xterm with the -ls option, or
> > > > > >B2) set "*loginShell: true" in your X resource database (c.f. 
> > > > > > xrdb(1))
> > > > > 
...
> > it really sounds like xterm is not starting a login shell. what is the 
> > output
> > of:
> > 
> > $ ps | grep xterm
> > 27150 p6  I   0:00.01 /bin/sh -c xterm -fg white -bg black -ls
> > 13224 p6  I   0:05.29 xterm
> >  6542 p6  I   0:01.18 xterm
> > 29777 p6  I   0:00.00 /bin/sh -c xterm -fg white -bg black -ls
> > 
> > you should see an '-ls' option at the end as above. if not, that is your
> > problem (it's not invoking a login shell), and this should work:
> 
> I know that xterm isn't being started with -ls option and it solve thw
> problem.
> 
> But this couldn't be normal, is it? Because my intention is not to use
> only xterm but also others term. emulators like st, and I would like to have
> they working as it does in any other system.
> If this is normal, will I need to configure and make sure that every
> term. emulator I'm using is loading .profile.

X has worked that way as long as i can remember. B2 below should work for
other terminals as well, since the terminal should read in those values from
xrdb (eg *loginShell). they are kind of like environment variables, and you
can generally set them in ~/.Xresources or ~/.Xdefaults. on my system:

$ cat ~/.Xdefaults
! $OpenBSD: dot.Xdefaults,v 1.3 2014/07/10 10:22:59 jasper Exp $
XTerm*loginShell:true

so quite normal, really, but i don't know why it's not the default for you
(since it seems to be for me). you probably want something like the above,
without the 'XTerm' part, as Mr. Guenther mentioned, so other terminals
match too.

but only way to know if another terminal works is to try!

> 
> > On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> > > B) tell xterm to start the shell inside it as a login shell, so that
> > > *that* will read your .profile.  This can be done by either:
> > >B1) start xterm with the -ls option, or
> > >B2) set "*loginShell: true" in your X resource database (c.f. xrdb(1))
> > 
> > also, xterm may be invoked elsewhere like in your ~/.xinitrc, so you would
> > need to fix it there, but the xrdb option should take care of that.
> 
> -- 
> Regards
> 
> Henrique Lengler 



Re: .kshrc Definitions under X

2015-04-10 Thread John Merriam

On 4/10/2015 8:03 PM, Henrique Lengler wrote:

On Fri, Apr 10, 2015 at 07:51:01PM -0400, dan mclaughlin wrote:

you should see an '-ls' option at the end as above. if not, that is your
problem (it's not invoking a login shell), and this should work:


I know that xterm isn't being started with -ls option and it solve thw
problem.

But this couldn't be normal, is it? Because my intention is not to use
only xterm but also others term. emulators like st, and I would like to have
they working as it does in any other system.
If this is normal, will I need to configure and make sure that every
term. emulator I'm using is loading .profile.


On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:

B) tell xterm to start the shell inside it as a login shell, so that
*that* will read your .profile.  This can be done by either:
B1) start xterm with the -ls option, or
B2) set "*loginShell: true" in your X resource database (c.f. xrdb(1))


also, xterm may be invoked elsewhere like in your ~/.xinitrc, so you would
need to fix it there, but the xrdb option should take care of that.


See the -l option of ksh.  Also search for the word login in the ksh man 
page.  ksh (and most if not all other shells I believe) behave 
differently if they think they are a login shell.  xterm does not not 
automatically tell the shell that is invoked when it starts that the 
shell should be a login shell.  That is why the -ls xterm option exists.


It can be useful not to tell the shell invoked by xterm that it is a 
login shell when you are running something in xterm besides an 
interactive command prompt session.  See the xterm man page.  You can 
run things in an xterm besides just a command prompt shell (shell 
scripts, other text programs, etc.) in which case you wouldn't want 
login shell type things being set up.


--

John Merriam



Re: .kshrc Definitions under X

2015-04-10 Thread Henrique Lengler
On Fri, Apr 10, 2015 at 07:51:01PM -0400, dan mclaughlin wrote:
> On Fri, 10 Apr 2015 18:49:02 -0300 Henrique Lengler  
> wrote:
> > On Fri, Apr 10, 2015 at 12:22:45AM -0400, dan mclaughlin wrote:
> > > On Thu, 9 Apr 2015 16:58:29 -0300 Henrique Lengler 
> > >  wrote:
> > > > On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> > > > > On Sun, Apr 5, 2015 at 9:12 PM, Andrew Fresh  
> > > > > wrote:
> > > > > > On Sun, Apr 05, 2015 at 10:50:47PM -0300, Henrique Lengler wrote:
> > > > > >> And it is called in ~.profile with this:
> > > > > >> . /home/henri/.kshrc
> > > > > >>
> > > > > >> The problem is that these definitions work out of X, in the 
> > > > > >> console,
> > > > > >> logged as the same user (henri) but don't work under X.
> > > > > >> I open a xterm window and and type clr, I receive:
> > > > > >> /bin/ksh: clr: not found
> > > > > >> But out of X it works, can someone help me to make this thing work
> > > > > >> normally?
> > > > > >
> > > > > >
> > > > > > What I have done is set "ENV=$HOME/.kshrc" in .profile, then 
> > > > > > whenever you
> > > > > > open a new shell, it will use that file as a shell startup file.
> > > > > 
> > > > > That's step one, but whether it's enough depends on how you start X.
> > > > > 
> > > > > If you start X from the command line with 'startx' then yes, using
> > > > > export ENV=$HOME/.kshrc in your .profile should be enough, because
> > > > > your X clients will inherit that in the environment from startx.
> > > > > 
> > > > > If you start X with xdm, then you need to either
> > > > > A) manually set ENV (or source your entire .profile) from your
> > > > > .xsession that xdm invokes, OR
> > > > > B) tell xterm to start the shell inside it as a login shell, so that
> > > > > *that* will read your .profile.  This can be done by either:
> > > > >B1) start xterm with the -ls option, or
> > > > >B2) set "*loginShell: true" in your X resource database (c.f. 
> > > > > xrdb(1))
> > > > 
> > > > Still not able to do this. My /home/henri/.profile have this:
> > > > 
> > > > export ENV="$HOME/.kshrc"
> > > > export LC_CTYPE="en_US.UTF-8"
> > > > export GOPATH=$HOME/go
> > > > PATH=$PATH:$HOME/Scripts
> > > > 
> > > > My .kshrc
> > > > -
> > > > export PS1='$PWD $ '
> > > > alias quit=exit
> > > > alias clr=clear
> > > > alias logout=exit
> > > > alias bye=exit
> > > > alias j=jobs
> > > > 
> > > > 
> > > > BUT printenv says:
> > > > --
> > > > /home/henri $ printenv
> > > > _=/usr/bin/printenv
> > > > XAUTHORITY=/home/henri/.Xauthority
> > > > LOGNAME=henri
> > > > WINDOWPATH=5
> > > > WINDOWID=6291457
> > > > HOME=/home/henri
> > > > LC_CTYPE=en_US.UTF-8
> > > > DISPLAY=:0
> > > > GOPATH=/home/henri/go
> > > > MAIL=/var/mail/henri
> > > > PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/home/henri/Scripts
> > > > SHELL=/bin/ksh
> > > > PS1=$PWD $
> > > > TERM=st-256color
> > > > USER=henri
> > > > 
> > > > Looks like it reads the PS1 env but not the rest, or they don't work.
> > > > Also I don't intend to use only xterm, but others term. emulators.
> > > 
> > > try adding some 'echo' statements in all of your startup scripts. ie
> > > 
> > >   echo "sourcing .profile"
> > >   echo "sourcing .kshrc"
> > > 
> > > to see if it is running them. then maybe add 'printenv' and 'alias' to 
> > > some
> > > to see what they print out during startup eg
> > > 
> > > alias clr
> > > alias clr=clear
> > > alias clr
> > > 
> > > the first should say 'not found', the one after should print your 
> > > definition.
> > 
> > It behave like this, when I log into ksh out of X.
> > This aliases are being applied correctly out of X, the problem is inside
> > it.
> 
> it really sounds like xterm is not starting a login shell. what is the output
> of:
> 
> $ ps | grep xterm
> 27150 p6  I   0:00.01 /bin/sh -c xterm -fg white -bg black -ls
> 13224 p6  I   0:05.29 xterm
>  6542 p6  I   0:01.18 xterm
> 29777 p6  I   0:00.00 /bin/sh -c xterm -fg white -bg black -ls
> 
> you should see an '-ls' option at the end as above. if not, that is your
> problem (it's not invoking a login shell), and this should work:

I know that xterm isn't being started with -ls option and it solve thw
problem.

But this couldn't be normal, is it? Because my intention is not to use
only xterm but also others term. emulators like st, and I would like to have
they working as it does in any other system.
If this is normal, will I need to configure and make sure that every
term. emulator I'm using is loading .profile.

> On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> > B) tell xterm to start the shell inside it as a login shell, so that
> > *that* will read your .profile.  This can be done by either:
> >B1) start xterm with the -ls option, or
> >B2) set "*loginShell: true" in your X resource database (c.f. xrdb(1))
> 
> also, xterm may be inv

Re: .kshrc Definitions under X

2015-04-10 Thread dan mclaughlin
On Fri, 10 Apr 2015 18:49:02 -0300 Henrique Lengler  
wrote:
> On Fri, Apr 10, 2015 at 12:22:45AM -0400, dan mclaughlin wrote:
> > On Thu, 9 Apr 2015 16:58:29 -0300 Henrique Lengler  
> > wrote:
> > > On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> > > > On Sun, Apr 5, 2015 at 9:12 PM, Andrew Fresh  wrote:
> > > > > On Sun, Apr 05, 2015 at 10:50:47PM -0300, Henrique Lengler wrote:
> > > > >> And it is called in ~.profile with this:
> > > > >> . /home/henri/.kshrc
> > > > >>
> > > > >> The problem is that these definitions work out of X, in the console,
> > > > >> logged as the same user (henri) but don't work under X.
> > > > >> I open a xterm window and and type clr, I receive:
> > > > >> /bin/ksh: clr: not found
> > > > >> But out of X it works, can someone help me to make this thing work
> > > > >> normally?
> > > > >
> > > > >
> > > > > What I have done is set "ENV=$HOME/.kshrc" in .profile, then whenever 
> > > > > you
> > > > > open a new shell, it will use that file as a shell startup file.
> > > > 
> > > > That's step one, but whether it's enough depends on how you start X.
> > > > 
> > > > If you start X from the command line with 'startx' then yes, using
> > > > export ENV=$HOME/.kshrc in your .profile should be enough, because
> > > > your X clients will inherit that in the environment from startx.
> > > > 
> > > > If you start X with xdm, then you need to either
> > > > A) manually set ENV (or source your entire .profile) from your
> > > > .xsession that xdm invokes, OR
> > > > B) tell xterm to start the shell inside it as a login shell, so that
> > > > *that* will read your .profile.  This can be done by either:
> > > >B1) start xterm with the -ls option, or
> > > >B2) set "*loginShell: true" in your X resource database (c.f. 
> > > > xrdb(1))
> > > 
> > > Still not able to do this. My /home/henri/.profile have this:
> > > 
> > > export ENV="$HOME/.kshrc"
> > > export LC_CTYPE="en_US.UTF-8"
> > > export GOPATH=$HOME/go
> > > PATH=$PATH:$HOME/Scripts
> > > 
> > > My .kshrc
> > > -
> > > export PS1='$PWD $ '
> > > alias quit=exit
> > > alias clr=clear
> > > alias logout=exit
> > > alias bye=exit
> > > alias j=jobs
> > > 
> > > 
> > > BUT printenv says:
> > > --
> > > /home/henri $ printenv
> > > _=/usr/bin/printenv
> > > XAUTHORITY=/home/henri/.Xauthority
> > > LOGNAME=henri
> > > WINDOWPATH=5
> > > WINDOWID=6291457
> > > HOME=/home/henri
> > > LC_CTYPE=en_US.UTF-8
> > > DISPLAY=:0
> > > GOPATH=/home/henri/go
> > > MAIL=/var/mail/henri
> > > PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/home/henri/Scripts
> > > SHELL=/bin/ksh
> > > PS1=$PWD $
> > > TERM=st-256color
> > > USER=henri
> > > 
> > > Looks like it reads the PS1 env but not the rest, or they don't work.
> > > Also I don't intend to use only xterm, but others term. emulators.
> > > -- 
> > > Regards
> > > 
> > > Henrique Lengler 
> > > 
> > 
> > try adding some 'echo' statements in all of your startup scripts. ie
> > 
> >   echo "sourcing .profile"
> >   echo "sourcing .kshrc"
> > 
> > to see if it is running them. then maybe add 'printenv' and 'alias' to some
> > to see what they print out during startup eg
> > 
> > alias clr
> > alias clr=clear
> > alias clr
> > 
> > the first should say 'not found', the one after should print your 
> > definition.
> 
> It behave like this, when I log into ksh out of X.
> This aliases are being applied correctly out of X, the problem is inside
> it.
> -- 
> Regards
> 
> Henrique Lengler 
> 

it really sounds like xterm is not starting a login shell. what is the output
of:

$ ps | grep xterm
27150 p6  I   0:00.01 /bin/sh -c xterm -fg white -bg black -ls
13224 p6  I   0:05.29 xterm
 6542 p6  I   0:01.18 xterm
29777 p6  I   0:00.00 /bin/sh -c xterm -fg white -bg black -ls

you should see an '-ls' option at the end as above. if not, that is your
problem (it's not invoking a login shell), and this should work:

On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> B) tell xterm to start the shell inside it as a login shell, so that
> *that* will read your .profile.  This can be done by either:
>B1) start xterm with the -ls option, or
>B2) set "*loginShell: true" in your X resource database (c.f. xrdb(1))

also, xterm may be invoked elsewhere like in your ~/.xinitrc, so you would
need to fix it there, but the xrdb option should take care of that.



Re: .kshrc Definitions under X

2015-04-10 Thread Henrique Lengler
On Fri, Apr 10, 2015 at 01:05:13PM +0200, Benny Lofgren wrote:
> On 2015-04-10 04:21, Henrique Lengler wrote:
> > Very strange.
> > I can manually set a alias running:
> > 
> > alias clr=clear
> > # an then run the clr command will work.
> > 
> > But If I try running the .kshrc file it don't work:
> > 
> > /home/henri $ ./.kshrc
> > /home/henri $ clr
> > /bin/ksh: clr: not found
> > 
> > /home/henri $ sh .kshrc
> > /home/henri $ clr
> > /bin/ksh: clr: not found
> 
> Why this doesn't work is because when you execute a script like above
> what the shell does is start a new shell, run the script in that shell
> and wait for it to exit before you get the next prompt.
> 
> What that means is that the *new* shell sets your aliases, shell
> variables and funtions, but they are then forgotten again when that
> shell exits. Your actual command shell never gets to see what is done.
> 
> If you on the other hand execute the script the way patrick keshishian
> suggests in his mail (*), a process normally called "sourcing the
> script", it runs in the same shell that you give commands to, just as if
> you had entered the script by hand with your keyboard.
> 
> And then it will Just Work . :-)
> 
> 
> (*) Like this:
> 
>   $ . ~/.kshrc

Ok, so executing it like this makes it work.

I puted some checks after each line, like this:


export PS1='$PWD $ '
echo ALIAS 1
alias ls='ls -p'

alias clr
alias clr=clear
alias clr

alias p='ps -l'
alias df='df -h'
--

And I receive this:
---
/home/henri $ . ~/.kshrc
ALIAS 1
clr alias not found
clr=clear
--

So the problem is to make this work under X. The alias are working out
of X and in X if applied by hand.

> From your questions I'm deducing that you are not very familiar with how
> the shell really works, especially when it comes to the interaction
> between unix processes. This is very useful knowledge!
> 
> The best source for information is always the man page!
> 
> ksh's man page is very big and probably intimidating at first, but I
> really, really recommend that you do "man ksh" and read  it!
> 
> It contains the answer to most of your problems, and a good
> understanding of how the shell works is essential for any budding unix
> hacker. :-)

I will read it.

-- 
Regards

Henrique Lengler 



Re: .kshrc Definitions under X

2015-04-10 Thread Henrique Lengler
On Fri, Apr 10, 2015 at 12:22:45AM -0400, dan mclaughlin wrote:
> On Thu, 9 Apr 2015 16:58:29 -0300 Henrique Lengler  
> wrote:
> > On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> > > On Sun, Apr 5, 2015 at 9:12 PM, Andrew Fresh  wrote:
> > > > On Sun, Apr 05, 2015 at 10:50:47PM -0300, Henrique Lengler wrote:
> > > >> And it is called in ~.profile with this:
> > > >> . /home/henri/.kshrc
> > > >>
> > > >> The problem is that these definitions work out of X, in the console,
> > > >> logged as the same user (henri) but don't work under X.
> > > >> I open a xterm window and and type clr, I receive:
> > > >> /bin/ksh: clr: not found
> > > >> But out of X it works, can someone help me to make this thing work
> > > >> normally?
> > > >
> > > >
> > > > What I have done is set "ENV=$HOME/.kshrc" in .profile, then whenever 
> > > > you
> > > > open a new shell, it will use that file as a shell startup file.
> > > 
> > > That's step one, but whether it's enough depends on how you start X.
> > > 
> > > If you start X from the command line with 'startx' then yes, using
> > > export ENV=$HOME/.kshrc in your .profile should be enough, because
> > > your X clients will inherit that in the environment from startx.
> > > 
> > > If you start X with xdm, then you need to either
> > > A) manually set ENV (or source your entire .profile) from your
> > > .xsession that xdm invokes, OR
> > > B) tell xterm to start the shell inside it as a login shell, so that
> > > *that* will read your .profile.  This can be done by either:
> > >B1) start xterm with the -ls option, or
> > >B2) set "*loginShell: true" in your X resource database (c.f. xrdb(1))
> > 
> > Still not able to do this. My /home/henri/.profile have this:
> > 
> > export ENV="$HOME/.kshrc"
> > export LC_CTYPE="en_US.UTF-8"
> > export GOPATH=$HOME/go
> > PATH=$PATH:$HOME/Scripts
> > 
> > My .kshrc
> > -
> > export PS1='$PWD $ '
> > alias quit=exit
> > alias clr=clear
> > alias logout=exit
> > alias bye=exit
> > alias j=jobs
> > 
> > 
> > BUT printenv says:
> > --
> > /home/henri $ printenv
> > _=/usr/bin/printenv
> > XAUTHORITY=/home/henri/.Xauthority
> > LOGNAME=henri
> > WINDOWPATH=5
> > WINDOWID=6291457
> > HOME=/home/henri
> > LC_CTYPE=en_US.UTF-8
> > DISPLAY=:0
> > GOPATH=/home/henri/go
> > MAIL=/var/mail/henri
> > PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/home/henri/Scripts
> > SHELL=/bin/ksh
> > PS1=$PWD $
> > TERM=st-256color
> > USER=henri
> > 
> > Looks like it reads the PS1 env but not the rest, or they don't work.
> > Also I don't intend to use only xterm, but others term. emulators.
> > -- 
> > Regards
> > 
> > Henrique Lengler 
> > 
> 
> try adding some 'echo' statements in all of your startup scripts. ie
> 
>   echo "sourcing .profile"
>   echo "sourcing .kshrc"
> 
> to see if it is running them. then maybe add 'printenv' and 'alias' to some
> to see what they print out during startup eg
> 
> alias clr
> alias clr=clear
> alias clr
> 
> the first should say 'not found', the one after should print your definition.

It behave like this, when I log into ksh out of X.
This aliases are being applied correctly out of X, the problem is inside
it.
-- 
Regards

Henrique Lengler 



Re: .kshrc Definitions under X

2015-04-09 Thread Henrique Lengler
On Thu, Apr 09, 2015 at 04:47:38PM -0400, Dutch Ingraham wrote:
> > Still not able to do this. My /home/henri/.profile have this:
> > 
> > export ENV="$HOME/.kshrc"
> > export LC_CTYPE="en_US.UTF-8"
> > export GOPATH=$HOME/go
> > PATH=$PATH:$HOME/Scripts
> > 
> > My .kshrc
> > -
> > export PS1='$PWD $ '
> > alias quit=exit
> > alias clr=clear
> > alias logout=exit
> > alias bye=exit
> > alias j=jobs
> > 
> > 
> > BUT printenv says:
> > --
> > /home/henri $ printenv
> > _=/usr/bin/printenv
> > XAUTHORITY=/home/henri/.Xauthority
> > LOGNAME=henri
> > WINDOWPATH=5
> > WINDOWID=6291457
> > HOME=/home/henri
> > LC_CTYPE=en_US.UTF-8
> > DISPLAY=:0
> > GOPATH=/home/henri/go
> > MAIL=/var/mail/henri
> > PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/home/henri/Scripts
> > SHELL=/bin/ksh
> > PS1=$PWD $
> > TERM=st-256color
> > USER=henri
> > 
> > Looks like it reads the PS1 env but not the rest, or they don't work.
> > Also I don't intend to use only xterm, but others term. emulators.
> > -- 
> > Regards
> > 
> > Henrique Lengler 
> > 
> While there are other things above that may cause you issues, the main
> one I see is the use of the st terminal emulator; I've had trouble with
> that in the past.  Have you tried just starting with xterm and
> troubleshooting from there forward?

Yes, I am trying both, but xterm don't work too by default, only with
-ls option.
-- 
Regards

Henrique Lengler 



Re: .kshrc Definitions under X

2015-04-09 Thread Henrique Lengler
On Thu, Apr 09, 2015 at 10:28:02PM +0200, Jan Vlach wrote:
> Hi Henrique,
> 
> I can see that both .kshrc and .profile are applied in printenv. Are you
> missing aliases? What is the output of alias command?

/home/henri $ alias
autoload='typeset -fu'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
local=typeset
login='exec login'
nohup='nohup '
r='fc -e -'
stop='kill -STOP'
type='whence -v'

> > On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> > > On Sun, Apr 5, 2015 at 9:12 PM, Andrew Fresh  wrote:
> > > > On Sun, Apr 05, 2015 at 10:50:47PM -0300, Henrique Lengler wrote:
> > > >> And it is called in ~.profile with this:
> > > >> . /home/henri/.kshrc
> > > >>
> > > >> The problem is that these definitions work out of X, in the console,
> > > >> logged as the same user (henri) but don't work under X.
> > > >> I open a xterm window and and type clr, I receive:
> > > >> /bin/ksh: clr: not found
> > > >> But out of X it works, can someone help me to make this thing work
> > > >> normally?
> > > >
> > > >
> > > > What I have done is set "ENV=$HOME/.kshrc" in .profile, then whenever 
> > > > you
> > > > open a new shell, it will use that file as a shell startup file.
> > > 
> > > That's step one, but whether it's enough depends on how you start X.
> > > 
> > > If you start X from the command line with 'startx' then yes, using
> > > export ENV=$HOME/.kshrc in your .profile should be enough, because
> > > your X clients will inherit that in the environment from startx.
> > > 
> > > If you start X with xdm, then you need to either
> > > A) manually set ENV (or source your entire .profile) from your
> > > .xsession that xdm invokes, OR
> > > B) tell xterm to start the shell inside it as a login shell, so that
> > > *that* will read your .profile.  This can be done by either:
> > >B1) start xterm with the -ls option, or
> > >B2) set "*loginShell: true" in your X resource database (c.f. xrdb(1))
> > 
> > Still not able to do this. My /home/henri/.profile have this:
> > 
> > export ENV="$HOME/.kshrc"
> > export LC_CTYPE="en_US.UTF-8"
> > export GOPATH=$HOME/go
> > PATH=$PATH:$HOME/Scripts
> > 
> > My .kshrc
> > -
> > export PS1='$PWD $ '
> > alias quit=exit
> > alias clr=clear
> > alias logout=exit
> > alias bye=exit
> > alias j=jobs
> > 
> > 
> > BUT printenv says:
> > --
> > /home/henri $ printenv
> > _=/usr/bin/printenv
> > XAUTHORITY=/home/henri/.Xauthority
> > LOGNAME=henri
> > WINDOWPATH=5
> > WINDOWID=6291457
> > HOME=/home/henri
> > LC_CTYPE=en_US.UTF-8
> > DISPLAY=:0
> > GOPATH=/home/henri/go
> > MAIL=/var/mail/henri
> > PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/home/henri/Scripts
> > SHELL=/bin/ksh
> > PS1=$PWD $
> > TERM=st-256color
> > USER=henri
> > 
> > Looks like it reads the PS1 env but not the rest, or they don't work.
> > Also I don't intend to use only xterm, but others term. emulators.
> > -- 
> > Regards
> > 
> > Henrique Lengler 
> > 
> 
> -- 
> Be the change you want to see in the world.

-- 
Regards

Henrique Lengler 



Re: .kshrc Definitions under X

2015-04-09 Thread Dutch Ingraham
> Still not able to do this. My /home/henri/.profile have this:
> 
> export ENV="$HOME/.kshrc"
> export LC_CTYPE="en_US.UTF-8"
> export GOPATH=$HOME/go
> PATH=$PATH:$HOME/Scripts
> 
> My .kshrc
> -
> export PS1='$PWD $ '
> alias quit=exit
> alias clr=clear
> alias logout=exit
> alias bye=exit
> alias j=jobs
> 
> 
> BUT printenv says:
> --
> /home/henri $ printenv
> _=/usr/bin/printenv
> XAUTHORITY=/home/henri/.Xauthority
> LOGNAME=henri
> WINDOWPATH=5
> WINDOWID=6291457
> HOME=/home/henri
> LC_CTYPE=en_US.UTF-8
> DISPLAY=:0
> GOPATH=/home/henri/go
> MAIL=/var/mail/henri
> PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/home/henri/Scripts
> SHELL=/bin/ksh
> PS1=$PWD $
> TERM=st-256color
> USER=henri
> 
> Looks like it reads the PS1 env but not the rest, or they don't work.
> Also I don't intend to use only xterm, but others term. emulators.
> -- 
> Regards
> 
> Henrique Lengler 
> 
While there are other things above that may cause you issues, the main
one I see is the use of the st terminal emulator; I've had trouble with
that in the past.  Have you tried just starting with xterm and
troubleshooting from there forward?



Re: .kshrc Definitions under X

2015-04-09 Thread Henrique Lengler
On Sun, Apr 05, 2015 at 09:22:03PM -0700, Philip Guenther wrote:
> On Sun, Apr 5, 2015 at 9:12 PM, Andrew Fresh  wrote:
> > On Sun, Apr 05, 2015 at 10:50:47PM -0300, Henrique Lengler wrote:
> >> And it is called in ~.profile with this:
> >> . /home/henri/.kshrc
> >>
> >> The problem is that these definitions work out of X, in the console,
> >> logged as the same user (henri) but don't work under X.
> >> I open a xterm window and and type clr, I receive:
> >> /bin/ksh: clr: not found
> >> But out of X it works, can someone help me to make this thing work
> >> normally?
> >
> >
> > What I have done is set "ENV=$HOME/.kshrc" in .profile, then whenever you
> > open a new shell, it will use that file as a shell startup file.
> 
> That's step one, but whether it's enough depends on how you start X.
> 
> If you start X from the command line with 'startx' then yes, using
> export ENV=$HOME/.kshrc in your .profile should be enough, because
> your X clients will inherit that in the environment from startx.
> 
> If you start X with xdm, then you need to either
> A) manually set ENV (or source your entire .profile) from your
> .xsession that xdm invokes, OR
> B) tell xterm to start the shell inside it as a login shell, so that
> *that* will read your .profile.  This can be done by either:
>B1) start xterm with the -ls option, or
>B2) set "*loginShell: true" in your X resource database (c.f. xrdb(1))

Still not able to do this. My /home/henri/.profile have this:

export ENV="$HOME/.kshrc"
export LC_CTYPE="en_US.UTF-8"
export GOPATH=$HOME/go
PATH=$PATH:$HOME/Scripts

My .kshrc
-
export PS1='$PWD $ '
alias quit=exit
alias clr=clear
alias logout=exit
alias bye=exit
alias j=jobs


BUT printenv says:
--
/home/henri $ printenv
_=/usr/bin/printenv
XAUTHORITY=/home/henri/.Xauthority
LOGNAME=henri
WINDOWPATH=5
WINDOWID=6291457
HOME=/home/henri
LC_CTYPE=en_US.UTF-8
DISPLAY=:0
GOPATH=/home/henri/go
MAIL=/var/mail/henri
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/home/henri/Scripts
SHELL=/bin/ksh
PS1=$PWD $
TERM=st-256color
USER=henri

Looks like it reads the PS1 env but not the rest, or they don't work.
Also I don't intend to use only xterm, but others term. emulators.
-- 
Regards

Henrique Lengler 



Re: .kshrc Definitions under X

2015-04-06 Thread Joseph Oficre
Hi, does the tips here help?
http://www.openbsd.org/faq/faq8.html#ksh

2015-04-06 7:22 GMT+03:00 Philip Guenther :

> On Sun, Apr 5, 2015 at 9:12 PM, Andrew Fresh  wrote:
> > On Sun, Apr 05, 2015 at 10:50:47PM -0300, Henrique Lengler wrote:
> >> And it is called in ~.profile with this:
> >> . /home/henri/.kshrc
> >>
> >> The problem is that these definitions work out of X, in the console,
> >> logged as the same user (henri) but don't work under X.
> >> I open a xterm window and and type clr, I receive:
> >> /bin/ksh: clr: not found
> >> But out of X it works, can someone help me to make this thing work
> >> normally?
> >
> >
> > What I have done is set "ENV=$HOME/.kshrc" in .profile, then whenever you
> > open a new shell, it will use that file as a shell startup file.
>
> That's step one, but whether it's enough depends on how you start X.
>
> If you start X from the command line with 'startx' then yes, using
> export ENV=$HOME/.kshrc in your .profile should be enough, because
> your X clients will inherit that in the environment from startx.
>
> If you start X with xdm, then you need to either
> A) manually set ENV (or source your entire .profile) from your
> .xsession that xdm invokes, OR
> B) tell xterm to start the shell inside it as a login shell, so that
> *that* will read your .profile.  This can be done by either:
>B1) start xterm with the -ls option, or
>B2) set "*loginShell: true" in your X resource database (c.f. xrdb(1))
>
>
> Philip Guenther



Re: .kshrc Definitions under X

2015-04-05 Thread Philip Guenther
On Sun, Apr 5, 2015 at 9:12 PM, Andrew Fresh  wrote:
> On Sun, Apr 05, 2015 at 10:50:47PM -0300, Henrique Lengler wrote:
>> And it is called in ~.profile with this:
>> . /home/henri/.kshrc
>>
>> The problem is that these definitions work out of X, in the console,
>> logged as the same user (henri) but don't work under X.
>> I open a xterm window and and type clr, I receive:
>> /bin/ksh: clr: not found
>> But out of X it works, can someone help me to make this thing work
>> normally?
>
>
> What I have done is set "ENV=$HOME/.kshrc" in .profile, then whenever you
> open a new shell, it will use that file as a shell startup file.

That's step one, but whether it's enough depends on how you start X.

If you start X from the command line with 'startx' then yes, using
export ENV=$HOME/.kshrc in your .profile should be enough, because
your X clients will inherit that in the environment from startx.

If you start X with xdm, then you need to either
A) manually set ENV (or source your entire .profile) from your
.xsession that xdm invokes, OR
B) tell xterm to start the shell inside it as a login shell, so that
*that* will read your .profile.  This can be done by either:
   B1) start xterm with the -ls option, or
   B2) set "*loginShell: true" in your X resource database (c.f. xrdb(1))


Philip Guenther



Re: .kshrc Definitions under X

2015-04-05 Thread Andrew Fresh
On Sun, Apr 05, 2015 at 10:50:47PM -0300, Henrique Lengler wrote:
> And it is called in ~.profile with this:
> . /home/henri/.kshrc
> 
> The problem is that these definitions work out of X, in the console,
> logged as the same user (henri) but don't work under X.
> I open a xterm window and and type clr, I receive:
> /bin/ksh: clr: not found
> But out of X it works, can someone help me to make this thing work
> normally?


What I have done is set "ENV=$HOME/.kshrc" in .profile, then whenever you
open a new shell, it will use that file as a shell startup file.

$ man ksh | grep -A2 '^  *ENV' 
 ENVIf this parameter is found to be set after any profile files
are executed, the expanded value is used as a shell startup
file.  It typically contains function and alias definitions.

l8rZ,
-- 
andrew - http://afresh1.com

The 3 great virtues of a programmer: Laziness, Impatience, and Hubris.
  --Larry Wall