Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Applications / Mac Applications / May 2005



Tip: Looking for answers? Try searching our database.

xterm and PATH

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Per Rønne - 08 May 2005 20:22 GMT
When I open an xtern I see the following PATH:

G4:~ per$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/Users/per:/usr/X11R6/bin
G4:~ per$

But from where does it come and how do I change it? It works as it
should in Terminal, bur for sure not in xterm.
Signature

Per Erik Rønne

Barry Margolin - 08 May 2005 21:06 GMT
> When I open an xtern I see the following PATH:
>
[quoted text clipped - 4 lines]
> But from where does it come and how do I change it? It works as it
> should in Terminal, bur for sure not in xterm.

Your xterm is probably not running as a login window, so it doesn't
execute your .profile.  Run xterm with the -L option (I think) and it
will be a login shell.

Signature

Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Per Rønne - 08 May 2005 21:30 GMT
> > When I open an xtern I see the following PATH:
> >
[quoted text clipped - 8 lines]
> execute your .profile.  Run xterm with the -L option (I think) and it
> will be a login shell.

Well, 'man xterm' says it is 'xterm -l' but it doesn't work.
Furthermore, you'll usually start xterm when you start X11 - directly
from the MacOS X Finder. Or with a cmd-N when you are in X11.
Signature

Per Erik Rønne

D P Schreber - 08 May 2005 21:53 GMT
> Well, 'man xterm' says it is 'xterm -l' but it doesn't work.

The man page says -l turns on logging.  To get a login shell, use -ls.

Or, better, configure your shell rc scripts to do the same thing in all
interactive shells, login or not.  Just make a symlink from .profile to
.bashrc.

> Furthermore, you'll usually start xterm when you start X11 - directly
> from the MacOS X Finder.

It runs the script /etc/X11/xinit/xinitrc, which you can edit, or copy
to your home directory as .xinitrc and edit.

You can also use the loginShell resource in ~/.Xresources so that all
xterms run login shells by default.

> Or with a cmd-N when you are in X11.

This is modifiable.  cmd-N in my X11.app runs rxvt.
Per Rønne - 09 May 2005 07:25 GMT
> > Well, 'man xterm' says it is 'xterm -l' but it doesn't work.

> The man page says -l turns on logging.  To get a login shell, use -ls.

Yes, that works.

> Or, better, configure your shell rc scripts to do the same thing in all
> interactive shells, login or not.  Just make a symlink from .profile to
> .bashrc.

Yes, that works too.

> > Furthermore, you'll usually start xterm when you start X11 - directly
> > from the MacOS X Finder.

> It runs the script /etc/X11/xinit/xinitrc, which you can edit, or copy
> to your home directory as .xinitrc and edit.

Seems straigtforward.

> You can also use the loginShell resource in ~/.Xresources so that all
> xterms run login shells by default.

Well, I don't even know what .Xresources should look like. I can't find
any and the way you write about it suggests that it isn't just a text
file.

> > Or with a cmd-N when you are in X11.

> This is modifiable.  cmd-N in my X11.app runs rxvt.

Which isn't even in my path. BTW, where do you change cmd-N?
Signature

Per Erik Rønne

D P Schreber - 09 May 2005 12:09 GMT
> Well, I don't even know what .Xresources should look like. I can't find
> any and the way you write about it suggests that it isn't just a text
> file.

It is.  A typical line looks like this:

xterm.loginShell: true

The piece before the colon names a resource, the piece after gives a
default value for that resource.  Resource names are of the form a.b.c..
to an arbitrary depth.  Most of the time they're just program.resource,
as above. So when the xterm man page refers to the 'loginShell'
resource, they're talking about the resource 'xterm.loginShell'.

If you look in the standard init file /etc/X11/xinit/xinitrc, you'll see
that one of things it does when the X server starts is:

if [ -f "$userresources" ]; then xrdb -merge "$userresources" fi

where $userresources is ~/.Xresources.  So if you have a file by that
name and it contains the line above, all xterms by default will run
login shells.  You can use the same mechanism to set many other defaults
attributes of xterms: background color, font, scrollback lines etc etc.

>> > Or with a cmd-N when you are in X11.
>
>> This is modifiable.  cmd-N in my X11.app runs rxvt.
>
> Which isn't even in my path.

Apple doesn't include the rxvt X11 terminal emulator, but it's easy to
build.  I prefer it to xterm.

> BTW, where do you change cmd-N?

The X11.app Applications menu lets you assign keyboard shortcuts to
little scripts, via 'Customize menu'.  By default it assigns cmd-n to
'xterm', but you're free to modify it.
Per Rønne - 09 May 2005 13:01 GMT
> > Well, I don't even know what .Xresources should look like. I can't find
> > any and the way you write about it suggests that it isn't just a text
[quoted text clipped - 3 lines]
>
> xterm.loginShell: true

OK, that explains why mine didn't work. I'd written:

XTerm*LoginShell:     true

> >> This is modifiable.  cmd-N in my X11.app runs rxvt.

> > Which isn't even in my path.

> Apple doesn't include the rxvt X11 terminal emulator, but it's easy to
> build.  I prefer it to xterm.

OK, I may try it. BTW, I also had to install ksh myself - though it
seems to come with the standard 10.4 package.

> > BTW, where do you change cmd-N?
>
> The X11.app Applications menu lets you assign keyboard shortcuts to
> little scripts, via 'Customize menu'.  By default it assigns cmd-n to
> 'xterm', but you're free to modify it.

I see now - and I see that I've known before. Just forgotten.

Thank you very much.
Signature

Per Erik Rønne

Dave Seaman - 09 May 2005 14:45 GMT
>> > Well, I don't even know what .Xresources should look like. I can't find
>> > any and the way you write about it suggests that it isn't just a text
[quoted text clipped - 3 lines]
>>
>> xterm.loginShell: true

> OK, that explains why mine didn't work. I'd written:

> XTerm*LoginShell:     true

That's what I've always used.  It works for me.
Did you restart X11 after installing this?

Signature

Dave Seaman
Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling.
<http://www.commoncouragepress.com/index.cfm?action=book&bookid=228>

Per Rønne - 09 May 2005 15:31 GMT
> >> > Well, I don't even know what .Xresources should look like. I can't find
> >> > any and the way you write about it suggests that it isn't just a text
[quoted text clipped - 10 lines]
> That's what I've always used.  It works for me.
> Did you restart X11 after installing this?

I think so. But of course I'm not sure.
Signature

Per Erik Rønne

Barry Margolin - 10 May 2005 02:32 GMT
> >> > Well, I don't even know what .Xresources should look like. I can't find
> >> > any and the way you write about it suggests that it isn't just a text
[quoted text clipped - 10 lines]
> That's what I've always used.  It works for me.
> Did you restart X11 after installing this?

It should work with either "." or "*", but I think the "l" has to be
lowercase in either case.

Signature

Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Dave Seaman - 10 May 2005 03:28 GMT
>> >> > Well, I don't even know what .Xresources should look like. I can't find
>> >> > any and the way you write about it suggests that it isn't just a text
[quoted text clipped - 10 lines]
>> That's what I've always used.  It works for me.
>> Did you restart X11 after installing this?

> It should work with either "." or "*", but I think the "l" has to be
> lowercase in either case.

I have been using it with a capital "L" for years, and it has always worked.
When I type "ps $$" in my xterm, the command I see is "-bash".

Signature

Dave Seaman
Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling.
<http://www.commoncouragepress.com/index.cfm?action=book&bookid=228>

Peter Breitfeld - 09 May 2005 11:56 GMT
Per Rønne schrieb:
> When I open an xtern I see the following PATH:
>
[quoted text clipped - 4 lines]
> But from where does it come and how do I change it? It works as it
> should in Terminal, bur for sure not in xterm.

maybe it's stored in .MacOS/environment.plist. Mine looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"\
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>LANG</key>
    <string>de_DE.UTF-8</string>
    <key>MM_CHARSET</key>
    <string>UTF-8</string>
    <key>PATH</key>
    <string>/sw/bin:/sw/sbin:/bin:/sbin:/usr/bin:/usr/sbin: \
  /usr/local/bin:/usr/X11R6/bin: \
  /usr/local/teTeX/bin/powerpc-apple-darwin-current: \
  /Developer/Tools:/usr/local/mysql/bin:/Users/brf/bin</string>
</dict>
</plist>

(No broken lines with \ in there!)

I have a .profile, which is symbolic link to .bashrc, so every terminal
-- login or not login -- reads the same stuff.

In the .bashrc I read in the contents of PATH and LANG like this:

export PATH=$(defaults read "${HOME}/.MacOSX/environment" PATH)
export LANG=$(defaults read "${HOME}/.MacOSX/environment" LANG)

So every OS X - Terminal and every xterm (X11) gets the same PATH and
LANG.  

Gruss Peter
Signature

==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

Per Rønne - 09 May 2005 13:22 GMT
> Per Rønne schrieb:
> > When I open an xtern I see the following PATH:
[quoted text clipped - 24 lines]
> </dict>
> </plist>

OK. Mine looks like this:

G4:~/.MacOSX per$ cat environment.plist              
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
       <key>TestEnvironmentVariable</key>
       <string>/sw/bin</string>
       <key>per</key>
       <string>1</string>
</dict>
</plist>
G4:~/.MacOSX per$ echo $TestEnvironmentVariable
/sw/bin
G4:~/.MacOSX per$ echo $per
1
G4:~/.MacOSX per$
===

And now the original PATH seem to have vanished - the one ending with:
/Users/per:/usr/X11R6/bin

> (No broken lines with \ in there!)

I knew:-).

> I have a .profile, which is symbolic link to .bashrc, so every terminal
> -- login or not login -- reads the same stuff.

I now have the opposite. A .bashrc which is a symbolic link to .profile.

> In the .bashrc I read in the contents of PATH and LANG like this:
>
[quoted text clipped - 3 lines]
> So every OS X - Terminal and every xterm (X11) gets the same PATH and
> LANG.  

Yes. I'll work it out - at present xterm have the same path, from
.profile. Is it better to have it from environment.plist?
Signature

Per Erik Rønne

Jochem Huhmann - 09 May 2005 13:49 GMT
> Yes. I'll work it out - at present xterm have the same path, from
> .profile. Is it better to have it from environment.plist?

The advantage of environment.plist is the fact that this sets the
environment globally and not just for processes started from a shell. If
you have some Carbon/Cocoa app that somehow needs something from the
environment, having it stuffed from the shell is useless since you don't
start Mac OS X apps from a shell, usually.

In my case it's Carbon Emacs that I would like to know about a custom
PATH and when you define your environment from .profile or such and
start Emacs from the GUI it won't see the variables set from there.

But take care, variables in environment.plist are not expanded by a
shell. You can't use things like $HOME or $PATH within, so this will
*not* work:

<key>PATH</key>
<string>$PATH:/usr/local/bin</string>

       Jochem

Signature

"A designer knows he has arrived at perfection not when there is no
longer anything to add, but when there is no longer anything to take away."
- Antoine de Saint-Exupery

Per Rønne - 09 May 2005 14:31 GMT
> > Yes. I'll work it out - at present xterm have the same path, from
> > .profile. Is it better to have it from environment.plist?
[quoted text clipped - 15 lines]
> <key>PATH</key>
> <string>$PATH:/usr/local/bin</string>

Which means I should expand them from .profile, like:

===
In the .bashrc I read in the contents of PATH and LANG like this:

export PATH=$(defaults read "${HOME}/.MacOSX/environment" PATH)
export LANG=$(defaults read "${HOME}/.MacOSX/environment" LANG)

So every OS X - Terminal and every xterm (X11) gets the same PATH and
LANG.  

Gruss Peter
===

And then expand them in the usual way?

Signature

Per Erik Rønne

Per Rønne - 09 May 2005 15:10 GMT
> Which means I should expand them from .profile, like:

And I've now done it like this:

G4:~ per$ cd .MacOSX
G4:~/.MacOSX per$ cat environment.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.
com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
       <key>PATH</key>

<string>/usr/bin:/bin:/usr/sbin:/sibn:/Users/per:/usr/X11R6/bin:/sw/bin:
/opt/local/bin:/usr/local/bin</string>
       <key>LANG</key>
       <string>dkDK</string>
       <key>MM_CHARSET</key>
       <string>UTF-U</string>
</dict>
</plist>
G4:~/.MacOSX per$ cd ..
G4:~ per$ cat .profile
export PATH=$(defaults read "${HOME}/.MacOSX/environment" PATH)
export LANG=$(defaults read "${HOME}/.MacOSX/environment" LANG)
alias a='alias'
alias la='ls -aFC'
alias ll='ls -alF'
. /sw/bin/init.sh
export a
export la
export ll
G4:~ per$ cat .Xresources
xterm.LoginShell:     true
G4:~ per$
G4:~ per$ echo $PATH
/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sibn:/Users/per:/usr/X11R6/bin
:/sw/bin:/opt/local/bin:/usr/local/bin
G4:~ per$ echo $LANG
dkDK
===

With soft links to .profile from .bash_profile and .bashrc.
Signature

Per Erik Rønne

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.