oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Learning the Mac OS X Terminal, Part 4
Pages: 1, 2, 3

Now while it's true we can perform the next step using any text editor, since you have the Developer Tools installed you have an even better tool for the job, the PropertyListEditor application, which you'll find in /Developer/Applications. So go ahead and open PropertyListEditor.

From the File menu, select Open, navigate to ~/Library/Application Support/Terminal, and open the streamripper.term file. Like plist files, the data in term files are arranged in a hierarchy with a "Root" level at the top. Clicking the Root level's disclosure triangle will expose the next level down, "WindowSettings." Disclose that level, and the "0" level below it and you'll then see the complete list of the term file’s properties, most of which will look familiar.

Next, scroll down to the "ExecutionString" line and double-click on its field in the "Value" column, which will select it for text entry.

Enter this string:

streamripper -d ~/Music/;open ~/Music/Japan-*;exit

And press Return to close that field. The string you entered is a single command line made of three commands, each separated by a semicolon. Joining commands in this way allows you to run commands sequentially (the next one running only when the previous has finished), just as if you entered them on three different lines. Therefore, the line you entered is equivalent to you first running Streamripper:

streamripper -d ~/Music/

and then once you've stopped the ripping, issuing this command:

open ~/Music/Japan-*

The open command opens the destination folder in the finder, allowing you to see your freshly ripped files. Since the destination folder is named for the "station" providing the stream, the pathname will, of course, be different for different stations. The * in the pathname is a wildcard character, letting you designate the directory by only its first few characters. Finally, the exit command terminates your shell session (always a good idea when you're done).

Now for the finishing touch. Scroll down to the "TerminalOpaqueness" line. This hidden setting allows you to set the window's transparency, which will give our window a realistic, glass-like appearance. The value you need to enter is the decimal equivalent of the desired percentage of opaqueness. The default setting of 1.0, then, results in a 100% opaque window. A good setting for our window will be .85, which will be just a bit transparent. Enter ".85" in the value field and press Return.

We're done with the term file and now only need to save it. From the File menu, select Save As and save the file with an appropriate new name (still appended with ".term") in the same directory as the original.

You might need to restart Terminal to see the file in your Library menu. Once it's there, select it and see your creation:

Finally, here are a few more points regarding term files and Streamripper that will help you make your own version of this file (and others):

Previously in the Series

Learning the Mac OS X Terminal: Part 1

Learning the Mac OS X Terminal, Part 2

Learning the Mac OS X Terminal, Part 3

  • A term file, when double-clicked in the Finder, opens and runs in Terminal just as if you had selected it from the Library menu. You might want to paste a custom icon onto your file and put it in the Dock, Toolbar, or Favorites folder. Or, you could make a folder full of different Streamripper term files for different stations and put that in the Dock.

  • Just as a crontab command line can reference a shell script, so can the command line you add to your term file, allowing you to do just about anything with a term file.

  • Terminal also recognizes double-clickable "command files," which are plain text and hold just command lines and scripts, and are named with .command at the end. Opening a command file in Terminal will open a new default window in which to run the command. This differs from a term file, which specifies the properties of the window. You'll find more about command files here.

  • Each Streamripper session will require a good chunk of CPU attention. Depending on your machine, you probably don't want to run more than a couple of sessions at once.

  • If you want to listen to the stream as you rip, add the -r (relay) flag to the Streamripper command, like this:

  • streamripper -r -d ~/Music/
    Then, open iTunes, select Open Stream from the Advanced menu, and enter this as the URL:localhost:8000
  • Some stations don't send the meta-data needed to break the stream into individual song files. In these cases, Streamripper will rip to one long file.

  • Not all Unix software installs on OS X as effortlessly as Streamripper. For hints on installing other packages, see this site.

With the procedures you've learned in this tutorial, you'll be able to take even more advantage of Mac OS X's Unix roots, as well as Terminal's unique capabilities. If you come up with any interesting term files of your own, feel free to share them in TalkBack.