Mac Terminal Tweaks

I spend most of my day in the terminal doing one thing or another. While the default setting work pretty well on the Mac, it’s lacking while connecting to a remote system. Here are some of the tweaks I’ve made to make the terminal app more useful for me.

Not all systems know how to handle a terminal type of xterm-color. I did find a terminal definition for xterm-color and successfully applied it to AIX, but I’d rather not do that to all my systems. So, you can change the terminal type to xterm by default. Under Terminal Preferences -> Settings -> Advanced, change the “Declare terminal as” to xterm. You can also select dtterm (not as well supported on AIX, and not color) or several flavors of vtterm.

For some reason, Apple thinks the page-up and page-down keys should scroll the buffer back. I’d rather actually use page-up and page-down in my terminal than just using it to scroll back. You can adjust the key codes under Terminal Preferences -> Settings -> Keyboard. Then, edit the keys and set them as:

page down: \033[6~
page up: \033[5~

You can also try:
Home: \001 or \033[7~
End: \005 or \033[4~

It also bugs me that the terminal doesn’t exit when I logout. I then end up going to the mouse and closing the window or hitting Command-W. You can make the terminal close, only if the program it’s running exits with a 0 return code. Go to Terminal Preferences -> Settings -> Shell, and change “When the shell exits” to “Close if the shell exited cleanly”.

I’d like it if the terminal name changed to the system I’m connected to, but I haven’t found how to do that yet. I have made the terminal window bar a little more useful. Under Terminal Preferences -> Settings -> Window, I have “Active process name”, “Dimensions”, and “Command key” checked. That gives me a window bar something like: Terminal – ssh – 80×24 – CMD4

I don’t care for the block cursor either. It tends to hide the character under the cursor in vi. So, I changed the cursor to a pipe. Under Terminal Preferences -> Settings -> Text, change the Cursor radio button to “| vertical bar”. You can also change it to an underscore.

While you’re in here, check out the different window themes. I’m using Homebrew now. It’s a nice green on black theme with just a little transparency. You can change your default new terminal session theme under Terminal Preferences -> Startup if you find one you like better.

DB2 for Mac install fails

What is it with IBM and products that fail to install?!?

I downloaded the beta of DB2 for Mac (version 9.5.2). The install went fine, until creating the actual instance. At which point it fails miserably. Firstly, it needs xcode installed, so signup for a free Apple Developer account and get that installed. After some digging, I found that the developer at IBM linked a bunch of executables to library files under /Users/rchase and /wsdb. Here is a quick script to resolve this by creating links in the right places:

mkdir /Users/rchase
mkdir /Users/rchase/build
mkdir /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1
mkdir /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/   
mkdir /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib

ln -s /opt/IBM/db2/V9.5/lib64/libdb2locale.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/
ln -s /opt/IBM/db2/V9.5/lib64/libdb2.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/
ln -s /opt/IBM/db2/V9.5/lib64/libdb2dascmn.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/
ln -s /opt/IBM/db2/V9.5/lib64/libdb2osse.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/
ln -s /opt/IBM/db2/V9.5/lib64/libdb2osse_db2.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/
ln -s /opt/IBM/db2/V9.5/lib64/libdb2install.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/
ln -s /opt/IBM/db2/V9.5/lib64/libdb2g11n.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/
ln -s /opt/IBM/db2/V9.5/lib64/libdb2genreg.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/
ln -s /opt/IBM/db2/V9.5/lib64/libdb2trcapi.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/
ln -s /opt/IBM/db2/V9.5/lib64/libdb2dasapi.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/
ln -s /opt/IBM/db2/V9.5/lib64/libdb2dasgcf.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/
ln -s /opt/IBM/db2/V9.5/lib64/libdb2sec.dylib /Users/rchase/build/rchase_db2_v95fp2_darwinport_darwin64_s081205_S1/INST/lib/

mkdir /wsdb
mkdir /wsdb/db2_v95fp2_darwinport
mkdir /wsdb/db2_v95fp2_darwinport/darwin64
mkdir /wsdb/db2_v95fp2_darwinport/darwin64/s081205
mkdir /wsdb/db2_v95fp2_darwinport/darwin64/s081205/INST
mkdir /wsdb/db2_v95fp2_darwinport/darwin64/s081205/INST/lib

ln -s  /opt/IBM/db2/V9.5/lib64/libdb2install.dylib /wsdb/db2_v95fp2_darwinport/darwin64/s081205/INST/lib/
ln -s  /opt/IBM/db2/V9.5/lib64/libdb2genreg.dylib /wsdb/db2_v95fp2_darwinport/darwin64/s081205/INST/lib/
ln -s  /opt/IBM/db2/V9.5/lib64/libdb2osse.dylib /wsdb/db2_v95fp2_darwinport/darwin64/s081205/INST/lib/
ln -s  /opt/IBM/db2/V9.5/lib64/libdb2trcapi.dylib /wsdb/db2_v95fp2_darwinport/darwin64/s081205/INST/lib/

After doing this, the programs don’t complain about missing libraries anymore…. I’m still unable to get db2icrt to create the instance, but I’m much closer than when I started. I would recommend doing the install, but make sure to select the option to not create any instances. Then, create the links to the missing files, and create the instance manually.