One thing geeks love about Mac OS X is that under the hood is the power of Unix, much of which is accessible via the shell (a command-line interface generally accessed via the Terminal program).
For complex Unix tasks, you want Terminal and all its features (or a third-party alternative such as iTerm). But many times your needs are much more basic—you just want to perform a few simple commands, run a program that doesn’t require any interaction, or tweak your Mac’s behavior using a tip you found on Mac OS X Hints. For these kinds of tasks, I’ve been testing Decimus Software’s DTerm 1.0.1
( ; $20).
Put simply, DTerm is a utility that provides instant access to your chosen Unix shell without having to open another program. Regardless of the application you’re currently using, just press DTerm’s keyboard shortcut and a small, command-line dialog appears at the top of the frontmost window. For example, if I’m in the Finder and invoke DTerm, its interface appears at the top of the Finder window in which I’m working:
What’s unique, and especially useful, about DTerm’s Terminal-like interface is that it automatically sets the shell’s current working directory—the “active” folder—to the location of the frontmost window. For example, if you activate DTerm from a Finder window, the current working directory will be that folder; you don’t need to issue a command to “switch” to the folder (as you would in Terminal). Similarly, if you activate DTerm from the window of a Word document, the shell’s current directory is automatically set to the folder containing that Word document. (You can see the path to the directory at the top of the DTerm display.) This is a super-convenient feature if you want to perform a shell command relating to the current document or folder.
There’s one quirk with this feature, however: If working in a folder located on the Desktop, and no file is selected, activating DTerm doesn’t use that folder as the current working directory; it instead uses the Desktop itself. For the auto-directory feature to work in this scenario, a file inside the folder must first be selected.
If you use the bash shell—the default in Leopard—DTerm supports the shell’s auto-complete feature; just press Tab to autocomplete commands and arguments.
After entering your command, press Return to execute it, just as you would in Terminal; any results—output generated by the command—are displayed below the command field.
Using the small left and right arrows at the top of the results display (or Command-left-arrow and Command-right-arrow, respectively), you can cycle through past commands and the results produced by each. Hit Escape, or the DTerm keyboard shortcut again, and DTerm disappears. You can hide DTerm while a command or program is running, coming back at a later time to check on it.
DTerm provides a number of other features, accessible via DTerm’s Action menu or convenient keyboard shortcuts, that are particularly handy given the utility’s contextual approach. Insert Selected Items pastes the path to the current folder or document into the shell field. This is especially useful in the Finder; for example, if you wanted to use the
zip command to create an archive of several files in a folder, just select the files, activate DTerm, type
zip archivename and then use the Insert Selected Items command to add all the files to the command as arguments.
The Copy Results And Dismiss command copies the output from your command to the Clipboard and hides DTerm; you can then paste that output into a document or email message. And if you ever want to re-use a command, you just switch to that command and its results, as described above, and then use Pull Command From Results. (This is similar to using the Up arrow in Terminal to go back to a previous command.)
Finally, if you ever want to execute a command in Terminal instead of in DTerm, just press Command+Return instead of Return; this launches Terminal and runs the command there. (Here’s a quick related tip: For quick access to Terminal, just invoke DTerm and press Command+Return without entering a command.)
Because DTerm is designed to be “hidden” until you want to use it, you can choose, via DTerm’s preferences, to keep the program from appearing in the Dock; you then access DTerm solely via its keyboard shortcut. With this option set, DTerm no longer acts as an application—which means it no longer has menus—so you access its preferences dialog, and quit the program, via the Action menu. However, in my testing, these options originally didn’t appear in the Action menu; after discussing the issue with the developer, I deleted DTerm’s preferences file and relaunched the program; this fixed the issue.
As useful and convenient as DTerm is, it also has its share of limitations as a shell interface. For starters, I found that DTerm sometimes has problems with particular characters; for example, if the name of a folder or file included an ampersand (&), certain commands failed when executed in DTerm. And I found it odd that although DTerm lets you use the
cd command to change to a different working directory, DTerm always forces the working directory back to the current window. So if you want to use a different directory in an argument, you have to include that directory path in the command itself; you can’t switch to it first. Finally, because DTerm is a simplified shell interface—the developer notes that DTerm is to Terminal as OS X’s Spotlight menu is to the Finder—it doesn’t currently work with commands and programs that require interaction (for example,
sudo, which requests your password).
Decimus Software is working to fix some of these issues for a future version. Still, even with these limitations, DTerm is great for executing simple commands, and I’ve found myself using it much more than I expected—and using Terminal much less.
DTerm 1.0.1 requires Mac OS X 10.5 or later.
Updated 2/20/2008 2:02pm to clarify the descriptions of two issues and to include a solution for another.