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.


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.

  • Do I literally include that text in the script? So it would look something like osascript -e 'tell app "Terminal" to do script "java -jar file.jar"' for running a Java file for example? Sep 26, 2017 at 23:18
  • @AaronFranke Yes, exactly.
    – slhck
    Sep 27, 2017 at 7:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .