Short answer: whichever suits you.
If your Unix background is mainly from Linux, you’re probably used to GNU commands. As you’ve noticed, they can be different from other Unix/Unix-based operating systems. Depending on how complex your scripts are, you can either:
make simple changes (like using ls -R .
instead of ls . -R
), which will work in most (if not all) Unix/Unix-based system and not only on GNU-based ones,
or install the GNU utilities from MacPorts if you think that there’d be too many/complex changes, or if you prefer to stick to the GNU commands you’re already used to.
If you want to take some time and write portable scripts, do it. If you think that’s not worth it, then don’t. Just bear in mind that not every Unix/Unix-based system uses GNU by default.
This is a little bit hacky, but you can achieve this in AppleScript. If there is a predetermined number of tabs you want, and preset commands you wish to run, this isn't difficult.
tell application "Terminal"
-- Activate it.
activate
set targetWindow to 0
-- Get a window that's not busy.
-- If there are no open windows, open one.
if count of windows is greater than 0 then
repeat with currentWindow in windows
if currentWindow is not busy then
set targetWindow to currentWindow
end if
end repeat
else
do script ""
set targetWindow to window 1
end if
-- Do command 1.
set firstCommand to "cd ~/Desktop; clear"
do script firstCommand in targetWindow
-- Open a new tab.
tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
if count of windows is greater than 0 then
repeat with currentWindow in windows
if currentWindow is not busy then
set targetWindow to currentWindow
end if
end repeat
else
do script ""
set targetWindow to window 1
end if
-- Do command 2.
set secondCommand to "cd /Applications; clear"
do script secondCommand in targetWindow
-- And so on...
end tell
Of course, replace firstCommand
with whichever command you actually want to run, and so on. For whatever reason, Terminal doesn't really have an accessible way to create new tabs through AppleScript, so the long, hacky looking line in the middle just tells Terminal to type ⌘T to open that new tab, and then new commands will execute in it.
You can run this AppleScript as is, or use it in Automator to create a new service, which you can then execute from anywhere using a keyboard shortcut if you'd like.
Extras - If you want to fire some script/command in the newly opened terminal session, you can refer this
Best Answer
According to Apple Developer documentation, the feature is available from OS X 10.6 or later.
Alternative to hardware-based GPS, how about DNS-based geolocation option for OSX 10.5? May be worth your time to google those.