Customize Terminal window commands
If you often use Terminal to perform a task, such as connecting to another computer via Secure Shell (SSH), you could save yourself a lot of time by harnessing Terminal’s ability to create saved sessions—in other words, saved Terminal commands. These sessions can have a completely customized look and can run any command. Activate them from the Finder or from within Terminal.
To create a saved session, open a new Terminal window, and then choose Terminal: Window Settings. This opens Terminal Inspector. Use its pop-up menu to access the different options for customizing the current window’s appearance. (Warning: At the bottom of each of Terminal Inspector’s panels, you’ll see the Use Settings As Defaults button. Don’t click on it! You don’t want to make these tweaked settings standard for all new windows—you want them to apply to just the saved session you’re creating.)
Change Your Fonts Choose Display from Terminal Inspector’s pop-up menu and click on the Set Font button to change the font and the type size for your Terminal session. For the
topcommand, for instance, you might use a smaller font, since you don’t really need to read every line closely.
Color Your Windows Choose Color from the pop-up menu to change your customized window’s color scheme. For instance, if you use SSH to connect to remote hosts, it could be useful to make those windows a different color than your local ones—set host1 to have a blue background, host2 to have a red background, and so on. In this way, you can easily identify remotely connected Terminal windows. You can pick from a number of color combinations (such as white text on a blue background) by clicking on the Standard Color Collections pop-up menu.
Size It Right Use the Window section to make the Terminal window a specific size (or resize it via the drag handles). Use a smaller window, say, for a session that runs the
topcommand, since its display is relatively narrow. In the Title text field, type a title—for example,
Remote to Host1for an SSH connection.
Get Quick Access Once you have everything set up, select File: Save As. In the Save dialog box that appears, give the session a name and leave the What To Save pop-up menu set to the default Main Window. Next, select the Execute This Command (Specify Complete Path) option. In the text field, enter the command you’d like to run in your saved session, and make sure the Execute Command In A Shell option is selected (see screenshot).
If you’re using Tiger, you can now access your saved session from Terminal’s File: Library menu. If you’re using Panther, you don’t automatically get access to this menu, but you can set it up yourself. Click here to read a longer version of this tip that shows how to do that, as well as how to access saved sessions from the Finder.
[ Senior Editor Rob Griffiths is the author of Mac OS X Power Hound, Panther Edition (O’Reilly, 2004), and runs the Mac OS X Hints Web site. ]Create easy-to-use Terminal sessions that handle repetitive tasks. Here’s one that edits my .bash_profile file.