Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use other terminal apps with Apple's X11 UNIX
There are many other hints about terminal-problems with all kinds of X11 and window managers, especially concerning cut and paste. I hate xterm, don't mind Terminal.app, but like iTerm.app the most. So I want Apple's X11 to launch iTerm instead of xterm, to have a nicer user interface and a functional cut and paste. My solution was to move the xterm binary from /usr/X11R6/bin/xterm to /usr/X11R6/bin/xterm_old, and place iTerm there instead. I had some difficulties with direct aliases or links, so I did the following. Place a file called xterm into /usr/X11R6/bin/ (after moving the original) and edit it. The only line is:
open /path/to/iTerm/iTerm.app
Now make it executable (chmod 755 xterm), and live happy ever after.

From now on, X11 will start up and open iTerm instead of xterm. SSH X-forwarding and everything else seems to work all right for me, so there's no drawback to my knowledge. You now have a nice terminal app with full cut and paste support. If you don't like iTerm, you can modify the one-line script to launch any other terminal program.

I know that people will probably not like to replace the xterm binary, but I just wanted to mention this here for those who don't have a problem with that. I would also be happy to see someone post the X11 preference entry which tells X11 which terminal application to use.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[18,478 views]  

Use other terminal apps with Apple's X11 | 13 comments | Create New Account
Click here to return to the 'Use other terminal apps with Apple's X11' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use other terminal apps with Apple's X11
Authored by: EddEdmondson on Aug 26, '04 11:47:18AM

Far safer in my opinion to do the following:

Make yourself an .xinitrc file ('cp /etc/X11/xinit/xinitrc ~/') if you don't already have your own in your home directory and edit the 'xterm &' line to 'open -a iTerm' or whatever in order to have an iTerm window start up alongside X11.app.

Then edit your X11.app Applications menu to add an iTerm menu option again using 'open -a'.

This leaves the xterm binary intact for other users too.



[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: isd_glory on Aug 26, '04 12:32:33PM
Rather than modifying xinitrc so X11 launches a terminal, I've modified xinitrc not to launch a terminal. This way you can somewhat do things in reverse by having your terminal program launch X11 instead. After modifying xinitrc, paste the following into your ~/.profile :
# if we're NOT ssh'd in
if [ ! ${SSH_TTY} ]; then
# make sure X is running
if [ "`ps -x | awk '{print $5}' | grep X11`" = "" ]; then
open /Applications/Utilities/X11.app &
# then refocus Terminal.app
osascript -e 'tell application "Terminal" to activate'
fi
# if DISPLAY isn't set
if [ x${DISPLAY} = x ]; then
export DISPLAY=:0
fi
fi
This way, any time you open Terminal.app, it sets itself up the X diaplay and makes sure X11 is running. It's a pretty simple solution if you don't mind X11 being active all the time. Additionally, it;s pretty easy to customize that one AppleScript line to suit your preferred terminal.

(I apologize if it appears i'm taking credit for that little script snippet; I found it somewhere on macosxhints a while ago, and cant seem to find a reference.)

[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: n8gray on Aug 26, '04 02:33:04PM

Sorry, but this hint is a terrible idea. There are plenty of good ways to use iTerm, Terminal, or whatever terminal you want with X but this isn't one of them. Any time you find yourself replacing a system file with a script it's a pretty good hint that you're doing something wrong. To do it right:

  • Method 1: Write your own $HOME/.xinitrc file that launches iTerm. Use /etc/X11/xinit/xinitrc as an example. With this technique you will only be able to launch X11 apps from the iTerm session that you launch with X11, and only if it's not already running before you start X11.
  • Method 2: Make any one iTerm know about the server. In an iTerm window type
    export DISPLAY=:0
    and you should now be able to use X11 programs in that window, provided the X11 server is running.
  • Method 3: Make all iTerms know about the server. Create a file called $HOME/.MacOSX/environment.plist with these contents:
    <?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>DISPLAY</key>
            <string>:0</string>
    </dict>
    </plist>
    
    Log out and log in again. Now any iTerm, Terminal.app, glTerm, or whatever should be able to launch X11 programs whenever the X11 server is running. This method is the same as the above method, but it applies to all programs. A similar technique would be to put
    export DISPLAY=:0
    in your $HOME/.bash_profile file, but that can cause complications if you're connecting to your machine remotely and it only works if you use bash as your shell.


[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: szedula on Aug 26, '04 09:24:34PM
Using "csh" (I don't know about "bash") n8gray's "complication":
...but that can cause complications if you're connecting to your machine remotely and it only works if you use bash as your shell.

Can be solved using the following in ".login":
if ($?REMOTEHOST) then
   setenv DISPLAY ${REMOTEHOST}:0.0
else
   setenv DISPLAY :0.0
endif
when the remote system is a Mac.

[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: MaxMarino on Aug 27, '04 09:31:10AM
This is the bash version:
if [ -z "$DISPLAY" ]; then
    if [ -n "$REMOTEHOST" ]; then
        export DISPLAY=$REMOTEHOST:0.0
    else
        export DISPLAY=:0.0
    fi
fi
and indeed it is ok if you are only user on your Mac: I have this on my Powerbook. You may add/merge with an hint submitted by Christoph in May this year:
# try to figure out DISPLAY cleverly
DISPLAY=""
for x in 0 1 2 3 4 5 6 7 8 9
do
  if [ -O /tmp/.X$x-lock ]
      then
      DISPLAY=:$x.0
      break
  fi
done
if [ -z "$DISPLAY" ]
    then
    echo "$USER has no X11 DISPLAY open" 1>&2
    exit 1
fi
export DISPLAY
the files in /tmp increments with users starting their X11 on their sessions so it sets the DISPLAY correctly with multiple users and FUS.

[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: EddEdmondson on Aug 27, '04 03:05:48AM

Good idea but there's one flaw with what you're doing:

The DISPLAY variable is only 0 if you are the first user running X11.app. If you FUS to another user and start another X11.app the DISPLAY variable will be 1. To do things properly you probably need a clever Applescript to switch to X11.app and try to get the variable from there and pass it back.

If you're the sole user on your machine you'll be fine - but beware if you aren't!!



[ Reply to This | # ]
Solution?
Authored by: EddEdmondson on Aug 27, '04 03:09:03AM

A possible alternative to the problems with the DISPLAY variable taking on other values - arrange for your .xinitrc file to place the DISPLAY variable in a file like '.x11appdisplay' in your home directory, and parse its contents if the X11.app is found to be running on the start of a shell. I'll leave the details of this as an exercise for the reader based on other posted scripts!



[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: 47ronin on Aug 26, '04 03:36:57PM

Agreed. This hint is _NOT_ how you're supposed to do things in X11! If you want to control the startup of X items, use .xinitrc ...do not arbitrarily overwrite binaries in your system except in worst case scenario troubleshooting.



[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: Pausanias on Aug 26, '04 05:30:02PM
Like others have said, it is much better to edit your .xinitrc than to replace the xterm binary.

However, there is another disadvantage to using iTerm, which is that you cannot take advantage of quartz-wm's ability to have the focus follow the mouse. Like Terminal, you have to click on each iTerm to make it active... fine if you're used to it, uncomfortable if you're not.

Finally, having used iTerm, I have to say that I've had stability problems with it. It's crashed for me in Panther several times.

If you're looking for an Xterm replacement, you could try eterm. It supports tabbing, but you have to compile eterm yourself (using the standard "./configure; make; sudo make install" routine). Or, try /usr/bin/screen (comes already installed on your mac). It's a steep learning curve, but once you're hooked on it, it's as good or better than any tabbed terminal. If it's fancy effects you're looking for (like transparency), try aterm via fink: "fink install aterm." All these programs run natively on X and so can support focus-follows mouse.

[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: learner on Aug 27, '04 06:26:11PM

Actually, you can use focus-follow-mouse with iTerm. I'm using iTerm ver 0.8.0 under OS X 10.3.5 and it works great. Just go to preferences and select "Focus follow mouse".

I haven't had any problems with stability. Never crashed once...



[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: chris_on_hints on Aug 27, '04 09:08:44AM
I stick with Terminal.app. I have set up a little applescript to open a new terminal window, and link it to X11. I saved the script as an application, and put a "open /path/to/app/XTerminal.app" entry in the application menu for X11.

tell application "Terminal"
	activate
	do script with command "setenv DISPLAY :0 ; clear ; echo 'Terminal linked to X11.'"
	tell window frontmost
		set background color to {0, 0, -32638, -4648}
		set normal text color to {-7118, -7118, -7118}
	end tell
end tell

This does the trick, and has a different text and background colour to the normal .term file used by Terminal.app for non-X11 use.

The applescript section to define text and background colours is also very useful. The best way to use them is to set up a terminal window colours and transparency as you want them, and use the following code to find out the settings:


tell application "Terminal" to set x to the background color of the front window

Replace "background color" with any of the 'window properties' that are found in the dictionary for Terminal.app (use the script editor for this). Paste the script into a script editor window, run it, and the setting you need to use will be in the 'result' box at the bottom.

[ Reply to This | # ]

Use other terminal apps with Apple's X11
Authored by: GaelicWizard on Aug 29, '04 04:32:19AM

This is by far one of the stupidest posts that I have seen on here in a long time. This is inherently broken and should never, at any time, be done by anybody.

Rob, I am amazed you let this one through. Did you read it?

JP

---
Pell



[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: ruebenschuss on Aug 31, '04 04:58:32AM
Guys,

I am unworthy ! - and I do apologize !
I was not aware that the upcoming terminal window is caused by the .xinitrc. I should have known, though, and it seems that I had some kind of oxygen insufficience in my brain when submitting that hint... When I read the first reply to the hint, I banged my head on the desk and changed my setup immedeately...

Anyway, this is why we love macosxhints... There are so many excellent guys out there and it's so good to get comments and helpful advice.

I apologize again and agree that the original hint should at least get a remark to read through the comments, first...

Thanks for your contribution,
Joachim.

[ Reply to This | # ]