Skip to content

Instantly share code, notes, and snippets.

@zthxxx
Last active April 7, 2020 04:16
Show Gist options
  • Save zthxxx/4da8e3c572f4425d34576d48d0a9d578 to your computer and use it in GitHub Desktop.
Save zthxxx/4da8e3c572f4425d34576d48d0a9d578 to your computer and use it in GitHub Desktop.
Alfred iTerm2 global active

What's this

active iTerm2 if not focus on iTerm2 else open a new tab

Preview

iTerm2 preview

Install

manual download iTerm2-global-active.alfredworkflow and double click to install

or download via curl and restart alfred

mkdir -p ~/Library/Application\ Support/Alfred\ 3/Alfred.alfredpreferences/workflows/user.workflow.iTerm2-global-active/
cd ~/Library/Application\ Support/Alfred\ 3/Alfred.alfredpreferences/workflows/user.workflow.iTerm2-global-active/
curl -s "https://gist.githubusercontent.com/zthxxx/4da8e3c572f4425d34576d48d0a9d578/raw/icon.png" -o ./icon.png
curl -s "https://gist.githubusercontent.com/zthxxx/4da8e3c572f4425d34576d48d0a9d578/raw/info.plist" -o ./info.plist
<?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>bundleid</key>
<string>me.zthxxx.alfred.item2</string>
<key>connections</key>
<dict>
<key>2E04938B-FA3B-4B69-BF36-30F9BD33A78E</key>
<array>
<dict>
<key>destinationuid</key>
<string>6BEE91B8-4108-46F4-B710-3ED9FA6964D8</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>58C8D8E9-8B93-45F7-AE03-EC3F03B02D6D</key>
<array>
<dict>
<key>destinationuid</key>
<string>6BA86BA3-7ACA-407F-8397-93B745C16187</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>2E04938B-FA3B-4B69-BF36-30F9BD33A78E</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>6BA86BA3-7ACA-407F-8397-93B745C16187</key>
<array>
<dict>
<key>destinationuid</key>
<string>7C16EDA7-340F-4684-9FF6-F3E03148ABFC</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
<key>createdby</key>
<string>zthxxx</string>
<key>description</key>
<string>active iTerm2 if not focus on iTerm2, or open a new tab</string>
<key>disabled</key>
<false/>
<key>name</key>
<string>iTerm2 global active</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>applescript</key>
<string>on alfred_script(q)
tell application "System Events"
tell process "iTerm2"
click menu item "New Tab with Current Profile" of menu 1 of menu bar item "Shell" of menu bar 1
end tell
end tell
end alfred_script</string>
<key>cachescript</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.action.applescript</string>
<key>uid</key>
<string>7C16EDA7-340F-4684-9FF6-F3E03148ABFC</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>inputstring</key>
<string>{var:focusedapp}</string>
<key>matchcasesensitive</key>
<true/>
<key>matchmode</key>
<integer>0</integer>
<key>matchstring</key>
<string>com.googlecode.iterm2</string>
</dict>
<key>type</key>
<string>alfred.workflow.utility.filter</string>
<key>uid</key>
<string>6BA86BA3-7ACA-407F-8397-93B745C16187</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>action</key>
<integer>0</integer>
<key>argument</key>
<integer>0</integer>
<key>focusedappvariable</key>
<true/>
<key>focusedappvariablename</key>
<string></string>
<key>hotkey</key>
<integer>17</integer>
<key>hotmod</key>
<integer>1310720</integer>
<key>hotstring</key>
<string>T</string>
<key>leftcursor</key>
<false/>
<key>modsmode</key>
<integer>0</integer>
<key>relatedAppsMode</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.trigger.hotkey</string>
<key>uid</key>
<string>58C8D8E9-8B93-45F7-AE03-EC3F03B02D6D</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>paths</key>
<array>
<string>/Applications/iTerm.app</string>
</array>
<key>toggle</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.action.launchfiles</string>
<key>uid</key>
<string>6BEE91B8-4108-46F4-B710-3ED9FA6964D8</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>inputstring</key>
<string>{var:focusedapp}</string>
<key>matchcasesensitive</key>
<true/>
<key>matchmode</key>
<integer>1</integer>
<key>matchstring</key>
<string>com.googlecode.iterm2</string>
</dict>
<key>type</key>
<string>alfred.workflow.utility.filter</string>
<key>uid</key>
<string>2E04938B-FA3B-4B69-BF36-30F9BD33A78E</string>
<key>version</key>
<integer>1</integer>
</dict>
</array>
<key>readme</key>
<string>Hotkeys can be configured to pass out a variable of the active app at the point the hotkey is triggered.
This workflow demonstrates how the active app variable can be used to filter connections based on context, allowing the hotkey to perform different tasks based on context.</string>
<key>uidata</key>
<dict>
<key>2E04938B-FA3B-4B69-BF36-30F9BD33A78E</key>
<dict>
<key>colorindex</key>
<integer>3</integer>
<key>note</key>
<string>activeapp is not iTerm2</string>
<key>xpos</key>
<integer>320</integer>
<key>ypos</key>
<integer>340</integer>
</dict>
<key>58C8D8E9-8B93-45F7-AE03-EC3F03B02D6D</key>
<dict>
<key>xpos</key>
<integer>80</integer>
<key>ypos</key>
<integer>200</integer>
</dict>
<key>6BA86BA3-7ACA-407F-8397-93B745C16187</key>
<dict>
<key>colorindex</key>
<integer>3</integer>
<key>note</key>
<string>activeapp is iTerm2</string>
<key>xpos</key>
<integer>320</integer>
<key>ypos</key>
<integer>110</integer>
</dict>
<key>6BEE91B8-4108-46F4-B710-3ED9FA6964D8</key>
<dict>
<key>colorindex</key>
<integer>4</integer>
<key>note</key>
<string>open iTerm2</string>
<key>xpos</key>
<integer>490</integer>
<key>ypos</key>
<integer>310</integer>
</dict>
<key>7C16EDA7-340F-4684-9FF6-F3E03148ABFC</key>
<dict>
<key>note</key>
<string>New Tab with Current Profile</string>
<key>xpos</key>
<integer>500</integer>
<key>ypos</key>
<integer>80</integer>
</dict>
</dict>
<key>version</key>
<string>1.0</string>
<key>webaddress</key>
<string>https://github.com/zthxxx</string>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment