OSXFAQ Mac OS X UNIX Tip-of-the-Day

Week 105 - Controlling Bash At Startup (18 April 2005)
by
Adrian Mayo - Editor, OSXFAQ
Tuesday - Make X11 Xterm Launch Login Shells
From Monday's tip it can be seen that Apple's Terminal.app launches a login shell while X11 xterm launches a non-login shell. To help rationalise this behaviour and get a consistent environment we can change X11 xterm to launch a login shell.
Make X11 launch login shells. Edit /etc/X11/xinit/xinitrc and change the line that invokes xterm:
xterm &
to:
xterm -ls &
Alternatively, to affect only your own account, create a file ~/.xinitrc which is a copy of /etc/X11/xinit/xinitrc, and make the same change.
Now X11 will start a login shell.
Even better. To ensure all xterm windows are login shells too, instead of the above create a file called ~/.Xdefaults
$ cat ~/.Xdefaults
# Default settings for X Applications
#
# xterm
XTerm*.LoginShell: True
Now xterm will start a login shell whether it is invoked by X11 on startup, or by typing 'xterm &' on the command line, or by the X11 Applications menu.
Customise the look of an xterm terminal by adding more lines to ~/.Xdefaults. For example:
XTerm*background: black
XTerm*foreground: white
XTerm*backdrop: white
XTerm*rightScrollBar: True
XTerm*ScrollBar: True
xterm*saveLines: 5000
XTerm*VT100*geometry: 100x55+10+10
(The reason X11 xterm launches non-login shells is that in most Unix systems X11 controls the root window and the correct environment has already been set up. In OS X Aqua controls the root window. Hence it is better for xterm to startup login shells so that they source the login scripts.)
If you want to learn more about Mac OS X Unix visit the Learning Center
click.
- For beginners: Mac OS X Unix Tutorials
- For detailed information on specific topics: Advanced Unix
- For OS X in gereral: Mac OS X Tutorials
|