Back to the Tips Index
If you are a terminal user you probably already know you can create an alias in your favorite shell to run any command you want, but that presupposes that you already have a Terminal window open.

How do you create an icon you can double-click to run a command in a new Terminal window? For example, you could create an icon you can double click on to launch an interactive ssh session to a server you frequenly log into.

There are two ways.

  1. Create a shell script with the extension .command. When double clicked it will run the script in a new Terminal window. (Thanks Mr. Kitty!)

  2. Create an applescript application. Start by entering the following into a file:
    tell application "Terminal"
    	do script "ssh someserver.somedomain.com -l username"
    	activate
    end tell
    

    Replace someserver.somedomain.com with your server's name (you will probably have to specify its domain name like the example shows) and replace username with your login name on that server. If you need to log in via a special port, you can specify -p portnum right before the -l argument.

    Now save the file with a name ending in .scpt. For example, if you wanted to log into a server called zim, you could name it zim.scpt. Make a note of where you are saving this application file.

    Now double-click the file in the finder and it will open the AppleScript editor. Choose "Save As" from the file menu. For the file type choose "Application" and give it a name (e.g. 'zim") and save it without an extension.

Regardless of which method you choose, you can now put an icon on the file.

Find an image with a preview icon you like. Or, if you have an image that doesn't have a preview icon, you can fix that with a simple application like ThumbsUp available from www.devon-technologies.com.

Install the ThumbsUp application and simply drag an image file onto its application icon. The file will get a preview icon that matches its content.

Once you have an image file with a preview icon you like, select the file in the finder (so it is highlighted) and the press apple-C to "copy" the icon.

Now find the script file created above. Select it in the finder and click apple-i to "Get Info" on the file. At the top of the Info window you will see the script icon associated with the file. Click it once and it will get a light blue halo around it. Now press apple-V to "Paste" the icon. The icon for the script should change to the one you copied above.

That's it! Now you can double-click the icon and it will launch the command in an interactive Terminal window.

All content copyright Howard Cohen 2008 , all rights reserved worlwide.
hoco(at)timefold(dot)com