Scripts for iTerm 2

This script relies on having the shell integration scripts installed. At least I think that’s what’s giving me the current path in my tab title. Anyway, your tab titles have to be in the format SHELL PATH (PROCESS), e.g. “fish /Users/ttscoff/Dropbox/Work/LEX (fish)”. Once that’s set up, you can use this for both name and address scripts:

tell application id "com.googlecode.iterm2"
	tell the current window
		tell the current session
			return item 2 of my split(get name, " ")
		end tell
	end tell
end tell

on split(theString, theDelimiter)
	set {atid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, theDelimiter}
	set _array to every text item of theString
	set AppleScript's text item delimiters to atid
	return _array
end split
1 Like

I’m not an iTerm user myself, but @grahamb here wrote internally:

Hook works with iTerm2, unless user checks “Preferences>Appearance>General>Exclude from Dock and ⌘-Tab Application Switcher”

From my testing, if that box is checked Hook can’t detect iTerm2, neither with [NSWorkspace menuBarOwningApplication] nor [NSWorkspace frontmostApplication] then not

I’ve been supposed to add it to the Linkable Mac Apps page. I’ve now added an entry about iTerm 2 and linked it to this forum topic ( √ 11:36 PM PT).

@grahamb, does Brett’s script work around the issue you identified?