Skip to content

Instantly share code, notes, and snippets.

@michaelbartnett
Created April 19, 2011 04:36
Show Gist options
  • Save michaelbartnett/926819 to your computer and use it in GitHub Desktop.
Save michaelbartnett/926819 to your computer and use it in GitHub Desktop.
Start iTerm if not started, close first window that pops up
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.bartnett.itermonlogin</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>{/path_to_your_script_folder}/launch_iterm_nowindow.applescript</string>
</array>
</dict>
</plist>
# Check if iTerm is running, if not then
# 1. Launch it
# 2. Close the first window that opens
# 3. Reactivate previous application
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
if not appIsRunning("iTerm") then
set current_app to (path to frontmost application as Unicode text)
if the (count of windows) is not 0 then
set current_window to name of front window
end if
tell application "iTerm"
activate
close current terminal
end tell
tell application current_app
activate
activate current_window
end tell
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment