Skip to content

Fixed bug with iTerm2 stable/nightly #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 55 additions & 55 deletions apple-scripts/iTermNightly/iTerm2-nightly-new-tab-default.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,63 @@ end scriptRun
on CommandRun(withCmd, withTheme, theTitle)
tell application "iTerm"
if it is not running then
tell application "iTerm"
activate
delay 0.2
try
close first window
end try
end tell

tell application "iTerm"
try
create window with profile withTheme
on error msg
create window with profile "Default"
end try
tell the current window
tell the current session
set name to theTitle
set profile to withTheme
write text withCmd
end tell
end tell
end tell
activate
if (count windows) is 0 then
NewWin(withTheme) of me
end if
SetWinParam(theTitle, withCmd) of me
else if (count windows) is 0 then
NewWin(withTheme) of me
SetWinParam(theTitle, withCmd) of me
else
--assume that iTerm is open and open a new tab
NewTab(withTheme) of me
SetTabParam(theTitle, withCmd) of me
end if
end tell
end CommandRun

on NewWin(argsTheme)
tell application "iTerm"
try
create window with profile argsTheme
on error msg
create window with profile "Default"
end try
end tell
end NewWin

on SetWinParam(argsTitle, argsCmd)
tell application "iTerm"
tell the current window
tell the current session
set name to argsTitle
write text argsCmd
end tell
end tell
end tell
end SetWinParam

on NewTab(argsTheme)
tell application "iTerm"
tell the current window
try
tell application "iTerm"
activate
tell the current window
try
create tab with profile withTheme
on error msg
create tab with profile "Default"
end try
tell the current tab
tell the current session
set name to theTitle
write text withCmd
end tell
end tell
end tell
end tell
create tab with profile withTheme
on error msg
--if all iTerm windows are closed the app stays open. In this scenario iTerm has no "current window" and will give an error when trying to create the new tab.
tell application "iTerm"
try
create window with profile withTheme
on error msg
create window with profile "Default"
end try
tell the current window
tell the current session
set name to theTitle
write text withCmd
end tell
end tell
end tell
create tab with profile "Default"
end try
end if
end tell
end tell
end CommandRun
end NewTab

on SetTabParam(argsTitle, argsCmd)
tell application "iTerm"
tell the current window
tell the current tab
tell the current session
set name to argsTitle
write text argsCmd
end tell
end tell
end tell
end tell
end SetTabParam
26 changes: 15 additions & 11 deletions apple-scripts/iTermNightly/iTerm2-nightly-new-window.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ on CommandRun(withCmd, withTheme, theTitle)
tell application "iTerm"
if it is not running then
activate
delay 0.2
try
close first window
end try
if (count windows) is 0 then
NewWin(withTheme) of me
end if
else
NewWin(withTheme) of me
end if
end tell
tell application "iTerm"
try
create window with profile withTheme
on error msg
create window with profile "Default"
end try
tell the current window
tell the current session
set name to theTitle
Expand All @@ -37,3 +31,13 @@ on CommandRun(withCmd, withTheme, theTitle)
end tell
end tell
end CommandRun

on NewWin(argsTheme)
tell application "iTerm"
try
create window with profile argsTheme
on error msg
create window with profile "Default"
end try
end tell
end NewWin
110 changes: 55 additions & 55 deletions apple-scripts/iTermStable/iTerm2-stable-new-tab-default.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,63 @@ end scriptRun
on CommandRun(withCmd, withTheme, theTitle)
tell application "iTerm"
if it is not running then
tell application "iTerm"
activate
delay 0.2
try
close first window
end try
end tell

tell application "iTerm"
try
create window with profile withTheme
on error msg
create window with profile "Default"
end try
tell the current window
tell the current session
set name to theTitle
set profile to withTheme
write text withCmd
end tell
end tell
end tell
activate
if (count windows) is 0 then
NewWin(withTheme) of me
end if
SetWinParam(theTitle, withCmd) of me
else if (count windows) is 0 then
NewWin(withTheme) of me
SetWinParam(theTitle, withCmd) of me
else
--assume that iTerm is open and open a new tab
NewTab(withTheme) of me
SetTabParam(theTitle, withCmd) of me
end if
end tell
end CommandRun

on NewWin(argsTheme)
tell application "iTerm"
try
create window with profile argsTheme
on error msg
create window with profile "Default"
end try
end tell
end NewWin

on SetWinParam(argsTitle, argsCmd)
tell application "iTerm"
tell the current window
tell the current session
set name to argsTitle
write text argsCmd
end tell
end tell
end tell
end SetWinParam

on NewTab(argsTheme)
tell application "iTerm"
tell the current window
try
tell application "iTerm"
activate
tell the current window
try
create tab with profile withTheme
on error msg
create tab with profile "Default"
end try
tell the current tab
tell the current session
set name to theTitle
write text withCmd
end tell
end tell
end tell
end tell
create tab with profile withTheme
on error msg
--if all iTerm windows are closed the app stays open. In this scenario iTerm has no "current window" and will give an error when trying to create the new tab.
tell application "iTerm"
try
create window with profile withTheme
on error msg
create window with profile "Default"
end try
tell the current window
tell the current session
set name to theTitle
write text withCmd
end tell
end tell
end tell
create tab with profile "Default"
end try
end if
end tell
end tell
end CommandRun
end NewTab

on SetTabParam(argsTitle, argsCmd)
tell application "iTerm"
tell the current window
tell the current tab
tell the current session
set name to argsTitle
write text argsCmd
end tell
end tell
end tell
end tell
end SetTabParam
26 changes: 15 additions & 11 deletions apple-scripts/iTermStable/iTerm2-stable-new-window.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ on CommandRun(withCmd, withTheme, theTitle)
tell application "iTerm"
if it is not running then
activate
delay 0.2
try
close first window
end try
if (count windows) is 0 then
NewWin(withTheme) of me
end if
else
NewWin(withTheme) of me
end if
end tell
tell application "iTerm"
try
create window with profile withTheme
on error msg
create window with profile "Default"
end try
tell the current window
tell the current session
set name to theTitle
Expand All @@ -37,3 +31,13 @@ on CommandRun(withCmd, withTheme, theTitle)
end tell
end tell
end CommandRun

on NewWin(argsTheme)
tell application "iTerm"
try
create window with profile argsTheme
on error msg
create window with profile "Default"
end try
end tell
end NewWin