Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Linux has a command x-terminal-emulator that will activate a new terminal emulator. And i believe it works with the set default emulator.

  1. Does OS X have a similar command or the same command?
  2. Do all Mac OS X versions have this option?

My intention is to have a bash script launch a new bash script in a new terminal window.

I do not have a Mac to test this right now.

share|improve this question

1 Answer 1

The x-terminal-emulator does not exist in OS X. It would rely on an alternatives system, which simply doesn't work that way on OS X. Instead, it defines default applications for certain MIME types, URI schemes, or file types. Simply put, that is.

The easiest and most portable way to launch a new Terminal.app window from within a shell is to run the following AppleScript command:

osascript -e 'tell app "Terminal" to do script ""'

If you additionally require focus on this new terminal window, run after that:

osascript -e 'tell app "Terminal" to activate'

To run a shell script from within that window, simply give do script the path to the shell script:

osascript -e 'tell app "Terminal" to do script "/path/to/script.sh"'

Again, if you require focus after that, run the second activate command from above.


Some users of OS X might have iTerm2 installed as a replacement for the default Terminal.app that ships with OS X. While it doesn't register as "default" terminal—in general there's no such notion of a "default terminal" in OS X—some users might choose to use it for certain URL schemes. See: Setting iTerm2 as the default terminal (OSX Lion)

Otherwise, there is no "preference" setting for users to choose iTerm2 over Terminal.app. If you want to use iTerm2 instead of Terminal.app, you can check out the following answer. iTerm2 doesn't accept do shell script and requires you to write text to its prompt.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.