As of Mac OS X Lion 10.7, Terminal makes this a little simpler:
If you create a terminal with Shell > New Command or Shell > New Remote Connection, then create a Window Group, there's a new checkbox to tell it to "restore all commands" as well. So you no longer have to customize settings profiles just to specify a command to run.
(These menu items always create windows. You can View > Show Tab Bar if necessary, then drag them together to arrange them as tabs in the same window.)
In fact, it will automatically restore (re-run) a small set of common "safe"† commands: anything listed in /etc/shells, screen, tmux, emacs, vi/vim, nano, pico, top, and sessions created with New Remote Connection (ssh, etc.).
Moreover, Terminal supports Lion's Resume: It will automatically restore open windows (including "safe" commands) if you quit and restart Terminal, without having to create a Window Group. (To get Resume to restore other commands, use custom settings profiles to specify commands, as mentioned in jtb's answer.)
† With the exception of top
, the individual commands I listed are only considered safe when run without arguments. The others each have arguments that could be destructive or surprising to users if run without user confirmation. The set of "safe" commands can be customized with defaults write com.apple.Terminal RestorableCommands -array ...
by setting the preference to an array of strings. To specify that it's safe to run a command with arguments, include an asterisk where arguments would be. The default value for this preference is: "screen", "tmux", "emacs", "vi", "vim", "nano", "pico", "top *"