Published on Mac|Life (http://www.maclife.com)


Can I run a Unix command every time I launch the Terminal?
Created 2007-01-04 11:40

HOLIDAY BUYING GUIDE
    • 10 1337 Gifts for H4x0r World Domination
    • 10 Gifts for the Mac Switcher
    • 10 Creative Gifts for Designers

    Sponsored
SEE MORE ARTICLES

FEATURES
  • The Complete iMac History -- Bondi to Aluminum
  • New Apple Products--as Imagined by the Elite Gadget Press
  • Satire: 10 Ideas Steve Pitched to Disney
  • 50 Common Mac Problems Solved
  • From iMac to iPhone: A Video Trip Down Apple Announcement Memory Lane
SEE MORE FEATURES
TOP STORIES
  • iPhone Captures 17% of Smartphone Market
  • New Macs! Redesigned White MacBook, LED iMacs, Mac mini Refresh, and a Magic Mouse
  • 69 Awesomely Free Snow Leopard Compatible Apps
  • Fifth-Generation iPod nano
  • Screencast Video: Create 3D Photo Effects in Final Cut Pro
SEE MORE TOP STORIES
news
Can I run a Unix command every time I launch the Terminal?
Posted 01/04/2007 at 1:40:59pm | by Niko Coucouvanis
  • commentComments
  • printPrint
  • emailEmail
  • Delicious
  • Digg
  • StumbleUpon
  • Reddit
  • Slashdot
  • MacBlips

You can execute a command every time Terminal launches...

 

...or open Terminal windows with specific settings. Or both!

 

Although it's utilitarian by definition and wears its no-frills-ness like a badge of honor, the Terminal has some nifty tricks up its sleeve for those who haven't yet earned the title of Unix Jock. As it turns out, there are a couple of ways to automate Unix commands based on the Terminal's behavior. For starters, you can set a blanket command to execute every time you launch the Terminal application. Just select Terminal > Preferences, check the radio button labeled Execute This Command (Specify Complete Path), and enter a command in the text field. You can type in a simple one, such as uptime (for a report of how long your Mac's been running) or who (to see if anyone is logged in), or you can run a preassembled script by typing in the path to the file.

 

You can also use similar trickery to attach a command or script to a saved Terminal window, so the command(s) only automate when you open a specific TERM file (that's Terminal-speak for a Terminal Window Settings file). On its own, a TERM file only specifies Terminal windows' settings: font and background color, buffer size, shell emulation, and other geeky goodness that you can set via the Terminal Inspector (File > Show Info). After tweaking a Terminal window's settings to your liking, select File > Save As; in the resulting dialog, supply a name (somename.term), and specify a command or file for Terminal to auto-execute every time you open the file (somefile.term). By default, Terminal saves your TERM files in user name/Library/Application Support/Terminal; double-click a TERM file to launch it, or launch the Terminal and select File > Library to see a list of all the TERM files you've saved.

 

COMMENTS: 1
TAGS: 
  • commentComments
  • printPrint
  • emailEmail
  • Delicious
  • Digg
  • StumbleUpon
  • Reddit
  • Slashdot
  • MacBlips
COMMENTS
  • Login or register to post comments

Source URL: http://www.maclife.com/Unix_commands_in_the_Terminal