Open Julia in iTerm2 by default, instead of Terminal

I installed Julia on macOS High Sierra (10.13.3) with brew cask install julia, and it opens in Apple Terminal by default.
I am completely new to AppleScript, so I don’t know how to change the default behavior of Julia so that it opens in iTerm2 by default. (App ID - com.googlecode.iterm2).

This is the script for starting Julia:

set RootPath to POSIX path of (path to me)
tell application id "com.apple.terminal"
	do script ("exec '" & RootPath & "Contents/Resources/julia/bin/julia'")
	activate
end tell

Any idea how this can be done?

4 Likes

I guess, and this is a GUESS,:

set RootPath to POSIX path of (path to me)
tell application id "com.googlecode.iterm2"
	do script ("exec '" & RootPath & "Contents/Resources/julia/bin/julia'")
	activate
end tell

How are you opening it? Why not just type “julia” from within iterm2? You may need to set up an alias for this to work.

It doesn’t work, I tried it yesterday too. It says, “expected end of line, but found script”. Don’t know what it means, though.

Yes, I can open it with Julia within iTerm2, but I prefer opening Julia through Spotlight (i.e. through the executable by searching it, and then running it), but the script that is run by Julia invokes Terminal by default, and not iTerm2 (and I can’t change the script so that it invokes iTerm2, don’t know why. Throws up an error). Just a matter of convenience.

Apologies for resurrecting an old thread but if you open /Applications/Julia-1.0.app/Contents/Resources/Scripts, you can change the file to something similar to:

set RootPath to POSIX path of (path to me)
tell application "iTerm"
	tell current window
		create tab with default profile command "/Applications/Julia-1.0.app/Contents/Resources/julia/bin/julia"
		activate
	end tell
end tell
4 Likes

Great!

Super thanks for the script, I learnt now something new. :grinning: