-
-
Save reyjrar/1769355 to your computer and use it in GitHub Desktop.
| (* | |
| * New-iTerm-Window.scpt | |
| * | |
| * Intended for use with QuickSilver | |
| * I mapped option-y to running this script to create | |
| * a new iTerm window on the current workspace | |
| * | |
| * Based on much Googling - very little "original" code here | |
| * Comments/Suggestions to [email protected] | |
| *) | |
| if isAppRunning("iTerm") then | |
| tell application "iTerm" | |
| set myterm to (make new terminal) | |
| tell myterm | |
| set mysession to (make new session at the end of sessions) | |
| tell mysession | |
| exec command "/bin/bash -l" | |
| end tell | |
| end tell | |
| activate | |
| end tell | |
| else | |
| activate application "iTerm" | |
| end if | |
| (* Code from Dweller on | |
| * http://codesnippets.joyent.com/posts/show/1124 | |
| *) | |
| on isAppRunning(appName) | |
| tell application "System Events" to (name of processes) contains appName | |
| end isAppRunning |
@ChrisBuchholz you saved my day!
I have modified the old version of "open terminal window in current folder"
`on run {input, parameters}
tell application "Finder"
set dir_path to quoted form of (POSIX path of (folder of the front window as alias))
end tell
CD_to(dir_path)
end run
on CD_to(theDir)
if application "iTerm" is running then
tell application "iTerm"
tell current window
create tab with default profile
tell current session
write text "cd " & theDir & ";clear;"
end tell
end tell
end tell
else
tell application "iTerm"
tell current window
tell current session
write text "cd " & theDir & ";clear;"
end tell
end tell
end tell
end if
activate application "iTerm"
end CD_to`
Thias was the old version. i dont remeber the source:
`on run {input, parameters}
tell application "Finder"
set dir_path to quoted form of (POSIX path of (folder of the front window as alias))
end tell
CD_to(dir_path)
end run
on CD_to(theDir)
tell application "iTerm"
tell current window
create tab with default profile
tell current session
write text "cd " & theDir & ";clear;"
end tell
end tell
end tell
end CD_to`
@ChrisBuchholz is simple and uncomplicated. Add it to a file, stick #!/usr/bin/osascript at the top, chmod +x it and then call it from your favorite automation utility. in my case, khd.
error "iTerm got an error: current tab of current window doesn’t understand the “write” message." number -1708 from current tab of current window
@ohammersmith: Indeed! Though, it's the iTerm 2 betas, right?