Using X11 with Terminal instead of xterm

I'm relatively dumb when it comes to all the unix configuration stuff. I use X11 on my Mac and remote log into a linux box, run apps there and xdisplay back to the Mac. All the other engineers around me think my system is way cool because the Mac's interface and Finder beats what they have on linux or solaris. This all works fine in xterm, but I really don't like xterm because I can do neat stuff like drag Finder items into it and I'm no fan of middle-clicking to do a copy. I'd like to do all this in good old Terminal.

So while X11 was running, here's what I used to do in xterm:

xhost + linux boxaddress
rlogin -l mueck linux boxaddress
setenv DISPLAY my mac_ipaddress:0
cd somewhere
run my linux executables

Can anybody please tell me how to do the above in Terminal? This is all happening within the building I work behind a firewall so I'm not sure I want things bogged down with on-the-fly encryption (I read somewhere about ssh but it was an out of context posting where this was suggested). We have hundreds of users within the building on linux or solaris boxes all doing the xhost/rlogin thing routinely.

Thanks.

17 PowerBook G4 1.67GHz, Mac OS X (10.4.6)

Posted on Jul 21, 2006 8:31 AM

Reply
5 replies

Jul 21, 2006 10:19 AM in response to Mick Mueck1

First, you need to get the DISPLAY environment variable set in Terminal and add X11's bin directory to your PATH. Add the following to your .bashrc file:

if [[ -z ${DISPLAY} ]]; then
export DISPLAY=:0.0
fi
export PATH=$PATH:/usr/X11R6/bin


Then make sure that .bash_profile sources .bashrc, like:

source .bashrc

Now, as long as X11 is running on your Mac, you can use Terminal for all those commands.

Jul 21, 2006 10:50 AM in response to Jeff Hubbach

Initially that didn't work because after editing my ~/.bashrc file and starting up a new shell I thought Terminal would automatically read that file. Only after I manually sourced it did it work (the problem was Terminal didn't understand the xhost command).

How do you get Terminal to automatically read ~/.bashrc when you open a new window?

Thanks again.

Jul 21, 2006 11:04 AM in response to Mick Mueck1

Hi Mick,
The only difference between Apple's terminal and xterm is that, since xterm is itself an X11 app, the display in xterm is set automatically. I usually set the display in Apple's terminal to "😮.0" instead of specifying the host. That way, if you run an X11 app locally it will use the UNIX socket to connect to the X11 window server.

If you're going to do the whole set display, open xhost route, you will also have to set nolisten_tcp to false in your ~/Library/Preferences/com.apple.x11.plist file. However, if you connect to your Linux box with "ssh -Y", all of that, including setting the display on the Linux box, is done for you automatically. Also, the X11 data goes through an ssh encrypted tunnel so when using ssh, all communications are encrypted. If the fact that it's infinitely more secure than rhost isn't that important, the ease alone should still be worth it. Considering network speeds, even fast networks, the encryption overhead isn't noticeable. The ease should impress some of your colleagues.

If you really want to impress your colleagues you should consider using AppleScripts to enhance your terminal's interaction with your machine. I can help get you started with the scripts I use to improve terminal interaction with the Finder. I use a combination of shell scripts, AppleScripts and aliases that I've archived at pos.dmg.gz and pos.tgz. The disk image has some extra AppleScripts that Bill Scott created. However, he continued developing them so his page, Terminal-Finder Interaction on OS X has more stuff and even (shudder) explanations of how to use it. He even made a Fink package out of it.

Personally I think that zsh should impress them more than anything. Bill Scott has also done a huge number of things to enhance the use of zsh on OS X, all of which you can read about on a another of his pages, surprising named zsh on OS X.
--
Gary
~~~~
Once is happenstance,
Twice is coincidence,
Three times is enemy action.
-- Auric Goldfinger

Jul 21, 2006 11:16 AM in response to Mick Mueck1

Hi again Mick,
Bash only reads the ~/.bashrc when the new shell isn't a login shell. A login shell is the first one you open after you start the machine. (if you close the login shell, the next one will again be a login shell) A login shell reads one of the files like ~/.bash_profile. For the full list, see the INVOCATION section of the bash man page.

To handle all scenarios you should probably source the ~/.bashrc from the ~/.bash_profile or vice versa. Of course zsh doesn't do any such silliness. (hint, hint)
--
Gary
~~~~
Lots of folks are forced to skimp to support
a government that won't.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Using X11 with Terminal instead of xterm

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.