When working inside a terminal window, there’s a quick shortcut you can use to open a file (read, launch an application on a specific file or set of files). The beauty of this trick is that the command will work as if you clicked on an application icon(s) in Finder. For example, if you request to open a file with an extension of xml, the application associated with that extension will be started and the specified file will be passed to the application.

The command I am referring to is open; read on to see a few examples:

From a terminal window, to all the files with a “.rb” extension (in the current directory):

> open *.rb

To launch a browser at a specified URL, try this:

> open http://macDeveloperTips.com

And to open Finder in the current directory:

> open .

You can get more information about using the open command by viewing the manual page:

> man open

I can’t count how many times I’ve found myself in Finder and wanted to jump to a terminal at the current path location. The Open Terminal application is one of those little gems that will make you wonder how you ever got along without it. If you spend any time at all moving between Finder and a terminal, read on…

Installing the application is as simple as extracting the zip file and dragging the OpenTerminal.app file into a location where you store other scripts, tools, utilities, etc. I have a folder within my home directory where I dump all this kind of stuff, so down the road when I bump into this folder I’ll have a clue where the applications came from.

With the app installed, open Finder and drag the application to the toolbar. You’ll see the icon appear as shown here:

The first time you run this application you will be presented will an impressive list of options. The defaults work fine, however, take a few minutes to read through each option. Depending on how you work, chances are you can configure this app to keep pace with you.

Clicking on the Shell config option (on the top left) will present even more configurations choices:

If you are not using the default shell on Mac OS X (bash) I recommend choosing the ‘pushd’ option as this is another really handy tool to have when bouncing around the file system (pushd/popd are built-in commands on bash).

From here forward, whenever you are in Finder and want to jump to a terminal, simply click on the Open Terminal icon, and you’ll be whisked off to a terminal window. Slick.

The latest version will only work on Leopard, however, you can download an older version for Tiger as well. The only downside to this application is that the source code is not included. I’ll keep my eyes peeled for a similar version that includes the source. If you find one first, please post a comment.

OpenTerminal also includes a contextual menu plugin for the Finder that adds a "Open Terminal" command, that is as close as right click…

I recently had to rename somewhere in the neighborhood of 100+ files as I was moving code from one platform to another. Obviously, I was looking for a quick solution, and what follows is the shell (Bash) script that I used to do the job:

Read more »

The followings two tips are for those who spend any amount of time in terminal windows. The first tip shows how to configure focus follows mouse, which is handy when you jump between multiple terminals. The second tip demonstrates how to configure the default window settings so when inside a terminal and you create a new terminal (in either a tab or window) the window settings match your preferred look and feel.
To configure focus follows mouse, enter the following in a terminal. You will need to close and re-open all open terminals:

defaults write com.apple.Terminal FocusFollowsMouse -string YES

You can give this effect a try by opening two terminals and moving the mouse between them. Note, this only applies to two separate terminal windows, not two terminals in separate tabs within one terminal window.

The next tip will set the default window settings for each new terminal window that is opened (from within a terminal):

defaults write com.apple.Terminal "Default Window Settings" -string Novel

Novel is my preferred (configured) setting for a terminal. To see what I am referring to, from a terminal enter the Preferences dialog and look at the Startup setting, which is shown below:

This is a little confusing, let me clarify. If you look closely at the text in the dialog above, it states On startup, open:… which translates to…when I startup a terminal window, use the Novel window settings. However, if you are in a terminal already and open a new terminal (cmd-N or cmd-T), the default window setting is Basic. So, the tip above tells the system when I am in a terminal, and I open another terminal, using the window settings I specified (not Basic).

Both of the above configurations can be set by editing the terminal property list file located here: ~/Library/Preferences/com.apple.Terminal.plist. If you double click on this file, the Property List Editor will open the file and you’ll see the two properties mentioned in the tips above, near the top of the list:

And while you have the property editor open, go ahead and take a few minutes to tweak a few other options. I think you’ll agree there, is an an odd sense of satisfaction in customizing your system. You may need to restart any open terminals to see changes take effect.

For those who are new to working with Unix, I want to take a moment to introduce aliases. The simplest means to think of an alias is as a text shortcut, used inside a Terminal window, to represent one or more commands. On second thought, maybe that isn’t the simplest means to describe an alias. Let me try again using an example…

Read more »

One of the joys of working on a Unix system is the ability to tweak various system settings, even better when you can do so from a command-line shell (terminal). The means to get there on Mac OS X is the defaults command. Using defaults you can read, write and delete various application and system preferences.

Read more »