Skip to content

Fixes for 1.2.7 #183

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 3 commits into from
Jul 24, 2016
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
36 changes: 24 additions & 12 deletions Shuttle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
0ADB3B0F178EF8DB004E9BB9 /* StatusIconAlt@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0ADB3B0B178EF8DB004E9BB9 /* StatusIconAlt@2x.png */; };
0ADB3B13178F3DE4004E9BB9 /* LaunchAtLoginController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0ADB3B12178F3DE4004E9BB9 /* LaunchAtLoginController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
7E74A7C61789CE2F0079E0D2 /* shuttle.default.json in Resources */ = {isa = PBXBuildFile; fileRef = 7E74A7C51789CE2F0079E0D2 /* shuttle.default.json */; };
A12D9BF01BCF2C73004F52A6 /* iTerm-stable-current-window.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A12D9BE71BCF2C72004F52A6 /* iTerm-stable-current-window.scpt */; };
A12D9BF11BCF2C73004F52A6 /* iTerm-stable-new-tab-default.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A12D9BE81BCF2C72004F52A6 /* iTerm-stable-new-tab-default.scpt */; };
A12D9BF21BCF2C73004F52A6 /* iTerm-stable-new-window.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A12D9BE91BCF2C72004F52A6 /* iTerm-stable-new-window.scpt */; };
A124BA191D45572B00218F2F /* iTerm2-stable-current-window.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A124BA161D45572B00218F2F /* iTerm2-stable-current-window.scpt */; };
A124BA1A1D45572B00218F2F /* iTerm2-stable-new-tab-default.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A124BA171D45572B00218F2F /* iTerm2-stable-new-tab-default.scpt */; };
A124BA1B1D45572B00218F2F /* iTerm2-stable-new-window.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A124BA181D45572B00218F2F /* iTerm2-stable-new-window.scpt */; };
A124BA1F1D4558E500218F2F /* iTerm-legacy-current-window.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A124BA1C1D4558E500218F2F /* iTerm-legacy-current-window.scpt */; };
A124BA201D4558E500218F2F /* iTerm-legacy-new-tab-default.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A124BA1D1D4558E500218F2F /* iTerm-legacy-new-tab-default.scpt */; };
A124BA211D4558E500218F2F /* iTerm-legacy-new-window.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A124BA1E1D4558E500218F2F /* iTerm-legacy-new-window.scpt */; };
A12D9BF31BCF2C73004F52A6 /* iTerm2-nightly-current-window.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A12D9BEA1BCF2C73004F52A6 /* iTerm2-nightly-current-window.scpt */; };
A12D9BF41BCF2C73004F52A6 /* iTerm2-nightly-new-tab-default.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A12D9BEB1BCF2C73004F52A6 /* iTerm2-nightly-new-tab-default.scpt */; };
A12D9BF51BCF2C73004F52A6 /* iTerm2-nightly-new-window.scpt in Resources */ = {isa = PBXBuildFile; fileRef = A12D9BEC1BCF2C73004F52A6 /* iTerm2-nightly-new-window.scpt */; };
Expand All @@ -42,9 +45,12 @@
0ADB3B12178F3DE4004E9BB9 /* LaunchAtLoginController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LaunchAtLoginController.m; sourceTree = "<group>"; };
7E72D21E178003ED00A6389C /* Shuttle.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Shuttle.entitlements; sourceTree = "<group>"; };
7E74A7C51789CE2F0079E0D2 /* shuttle.default.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = shuttle.default.json; sourceTree = "<group>"; };
A12D9BE71BCF2C72004F52A6 /* iTerm-stable-current-window.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm-stable-current-window.scpt"; sourceTree = "<group>"; };
A12D9BE81BCF2C72004F52A6 /* iTerm-stable-new-tab-default.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm-stable-new-tab-default.scpt"; sourceTree = "<group>"; };
A12D9BE91BCF2C72004F52A6 /* iTerm-stable-new-window.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm-stable-new-window.scpt"; sourceTree = "<group>"; };
A124BA161D45572B00218F2F /* iTerm2-stable-current-window.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm2-stable-current-window.scpt"; sourceTree = "<group>"; };
A124BA171D45572B00218F2F /* iTerm2-stable-new-tab-default.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm2-stable-new-tab-default.scpt"; sourceTree = "<group>"; };
A124BA181D45572B00218F2F /* iTerm2-stable-new-window.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm2-stable-new-window.scpt"; sourceTree = "<group>"; };
A124BA1C1D4558E500218F2F /* iTerm-legacy-current-window.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm-legacy-current-window.scpt"; sourceTree = "<group>"; };
A124BA1D1D4558E500218F2F /* iTerm-legacy-new-tab-default.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm-legacy-new-tab-default.scpt"; sourceTree = "<group>"; };
A124BA1E1D4558E500218F2F /* iTerm-legacy-new-window.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm-legacy-new-window.scpt"; sourceTree = "<group>"; };
A12D9BEA1BCF2C73004F52A6 /* iTerm2-nightly-current-window.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm2-nightly-current-window.scpt"; sourceTree = "<group>"; };
A12D9BEB1BCF2C73004F52A6 /* iTerm2-nightly-new-tab-default.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm2-nightly-new-tab-default.scpt"; sourceTree = "<group>"; };
A12D9BEC1BCF2C73004F52A6 /* iTerm2-nightly-new-window.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTerm2-nightly-new-window.scpt"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -96,9 +102,12 @@
A12D9BE61BCF2C72004F52A6 /* apple-scpt */ = {
isa = PBXGroup;
children = (
A12D9BE71BCF2C72004F52A6 /* iTerm-stable-current-window.scpt */,
A12D9BE81BCF2C72004F52A6 /* iTerm-stable-new-tab-default.scpt */,
A12D9BE91BCF2C72004F52A6 /* iTerm-stable-new-window.scpt */,
A124BA1C1D4558E500218F2F /* iTerm-legacy-current-window.scpt */,
A124BA1D1D4558E500218F2F /* iTerm-legacy-new-tab-default.scpt */,
A124BA1E1D4558E500218F2F /* iTerm-legacy-new-window.scpt */,
A124BA161D45572B00218F2F /* iTerm2-stable-current-window.scpt */,
A124BA171D45572B00218F2F /* iTerm2-stable-new-tab-default.scpt */,
A124BA181D45572B00218F2F /* iTerm2-stable-new-window.scpt */,
A12D9BEA1BCF2C73004F52A6 /* iTerm2-nightly-current-window.scpt */,
A12D9BEB1BCF2C73004F52A6 /* iTerm2-nightly-new-tab-default.scpt */,
A12D9BEC1BCF2C73004F52A6 /* iTerm2-nightly-new-window.scpt */,
Expand Down Expand Up @@ -232,22 +241,25 @@
A12D9BF61BCF2C73004F52A6 /* terminal-current-window.scpt in Resources */,
A12D9BF31BCF2C73004F52A6 /* iTerm2-nightly-current-window.scpt in Resources */,
A12D9BF51BCF2C73004F52A6 /* iTerm2-nightly-new-window.scpt in Resources */,
A12D9BF21BCF2C73004F52A6 /* iTerm-stable-new-window.scpt in Resources */,
0ADB3B0D178EF8DB004E9BB9 /* StatusIcon.png in Resources */,
A12D9BF11BCF2C73004F52A6 /* iTerm-stable-new-tab-default.scpt in Resources */,
A124BA1F1D4558E500218F2F /* iTerm-legacy-current-window.scpt in Resources */,
0ADB3B0C178EF8DB004E9BB9 /* StatusIconAlt.png in Resources */,
C149EC0815D5214600B1F558 /* InfoPlist.strings in Resources */,
A1D700091A5DCFE1003563E4 /* AboutWindowController.xib in Resources */,
0ADB3B0F178EF8DB004E9BB9 /* StatusIconAlt@2x.png in Resources */,
0ADB3B0E178EF8DB004E9BB9 /* StatusIcon@2x.png in Resources */,
A124BA191D45572B00218F2F /* iTerm2-stable-current-window.scpt in Resources */,
A12D9BF41BCF2C73004F52A6 /* iTerm2-nightly-new-tab-default.scpt in Resources */,
C149EC0E15D5214600B1F558 /* Credits.rtf in Resources */,
A12D9BF01BCF2C73004F52A6 /* iTerm-stable-current-window.scpt in Resources */,
A12D9BF71BCF2C73004F52A6 /* terminal-new-tab-default.scpt in Resources */,
C149EC1415D5214600B1F558 /* MainMenu.xib in Resources */,
A124BA1B1D45572B00218F2F /* iTerm2-stable-new-window.scpt in Resources */,
A124BA1A1D45572B00218F2F /* iTerm2-stable-new-tab-default.scpt in Resources */,
C159DC2815D5DE8000F5DE24 /* shuttle.icns in Resources */,
A12D9BF81BCF2C73004F52A6 /* terminal-new-window.scpt in Resources */,
7E74A7C61789CE2F0079E0D2 /* shuttle.default.json in Resources */,
A124BA201D4558E500218F2F /* iTerm-legacy-new-tab-default.scpt in Resources */,
A124BA211D4558E500218F2F /* iTerm-legacy-new-window.scpt in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
44 changes: 33 additions & 11 deletions Shuttle/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ - (void) buildMenu:(NSArray*)data addToMenu:(NSMenu *)m {
NSString *menuName = cfg[@"name"];

//Place the terminal command, theme, and title into an comma delimited string
NSString *menuRepObj = [NSString stringWithFormat:@"%@,%@,%@,%@,%@", menuCmd, termTheme, termTitle, termWindow, menuName];
NSString *menuRepObj = [NSString stringWithFormat:@"%@¬_¬%@¬_¬%@¬_¬%@¬_¬%@", menuCmd, termTheme, termTitle, termWindow, menuName];

[menuItem setTitle:cfg[@"name"]];
[menuItem setRepresentedObject:menuRepObj];
Expand All @@ -383,7 +383,7 @@ - (void) openHost:(NSMenuItem *) sender {


//Place the comma delimited string of menu item settings into an array
NSArray *objectsFromJSON = [[sender representedObject] componentsSeparatedByString:(@",")];
NSArray *objectsFromJSON = [[sender representedObject] componentsSeparatedByString:(@"¬_¬")];

//This is our command that will be run in the terminal window
NSString *escapedObject;
Expand Down Expand Up @@ -443,10 +443,15 @@ - (void) openHost:(NSMenuItem *) sender {
}
}

//Set Paths to iTerm Legacy AppleScripts
NSString *iTermLegacyNewWindow = [[NSBundle mainBundle] pathForResource:@"iTerm-legacy-new-window" ofType:@"scpt"];
NSString *iTermLegacyCurrentWindow = [[NSBundle mainBundle] pathForResource:@"iTerm-legacy-current-window" ofType:@"scpt"];
NSString *iTermLegacyNewTabDefault = [[NSBundle mainBundle] pathForResource:@"iTerm-legacy-new-tab-default" ofType:@"scpt"];

//Set Paths to iTerm Stable AppleScripts
NSString *iTermStableNewWindow = [[NSBundle mainBundle] pathForResource:@"iTerm-stable-new-window" ofType:@"scpt"];
NSString *iTermStableCurrentWindow = [[NSBundle mainBundle] pathForResource:@"iTerm-stable-current-window" ofType:@"scpt"];
NSString *iTermStableNewTabDefault = [[NSBundle mainBundle] pathForResource:@"iTerm-stable-new-tab-default" ofType:@"scpt"];
NSString *iTermStableNewWindow = [[NSBundle mainBundle] pathForResource:@"iTerm2-stable-new-window" ofType:@"scpt"];
NSString *iTermStableCurrentWindow = [[NSBundle mainBundle] pathForResource:@"iTerm2-stable-current-window" ofType:@"scpt"];
NSString *iTermStableNewTabDefault = [[NSBundle mainBundle] pathForResource:@"iTerm2-stable-new-tab-default" ofType:@"scpt"];

//Set Paths to iTerm Nightly AppleScripts
NSString *iTerm2NightlyNewWindow = [[NSBundle mainBundle] pathForResource:@"iTerm2-nightly-new-window" ofType:@"scpt"];
Expand Down Expand Up @@ -474,11 +479,11 @@ - (void) openHost:(NSMenuItem *) sender {
else if ( [terminalPref rangeOfString: @"iterm"].location !=NSNotFound ) {

//If the JSON prefs for iTermVersion are not stable or nightly throw an error
if( ![iTermVersionPref isEqualToString: @"stable"] && ![iTermVersionPref isEqualToString:@"nightly"] ) {
if( ![iTermVersionPref isEqualToString: @"legacy"] && ![iTermVersionPref isEqualToString: @"stable"] && ![iTermVersionPref isEqualToString:@"nightly"] ) {

if( iTermVersionPref == 0 ) {
errorMessage = @"\"iTerm_version\": \"VALUE\", is missing.\n\"VALUE\" can be \"stable\" or \"nightly\"\n\nPlease fix your shuttle JSON settings.\nSee readme.md on shuttle's github for help.";
errorInfo = @"Press Continue to try iTerm stable applescripts.\n -->(not recommended)<--\nThis will fail if you have iTerm nightly installed.\n\nPlease fix the JSON settings.\nPress Quit to exit shuttle.";
errorMessage = @"\"iTerm_version\": \"VALUE\", is missing.\n\n\"VALUE\" can be:\n\"legacy\" targeting iTerm 2.14\n\"stable\" targeting new versions.\n\"nightly\" targeting nightly builds.\n\nPlease fix your shuttle JSON settings.\nSee readme.md on shuttle's github for help.";
errorInfo = @"Press Continue to try iTerm stable applescripts.\n -->(not recommended)<--\nThis will fail if you have another version of iTerm installed.\n\nPlease fix the JSON settings.\nPress Quit to exit shuttle.";
[self throwError:errorMessage additionalInfo:errorInfo continueOnErrorOption:YES];
iTermVersionPref = @"stable";

Expand All @@ -489,9 +494,26 @@ - (void) openHost:(NSMenuItem *) sender {
}
}

if( [iTermVersionPref isEqualToString:@"stable"]) {
if( [iTermVersionPref isEqualToString:@"legacy"]) {

//run the applescript that works with iTerm Stable
//run the applescript that works with iTerm Legacy
//if we are running in a new iTerm "Stable" Window
if ( [terminalWindow isEqualToString:@"new"] ) {
[self runScript:iTermLegacyNewWindow handler:handlerName parameters:passParameters];
}
//if we are running in the current iTerm "Stable" Window
if ( [terminalWindow isEqualToString:@"current"] ) {
[self runScript:iTermLegacyCurrentWindow handler:handlerName parameters:passParameters];
}
//we are using the default action of shuttle... The active window in a new tab
if ( [terminalWindow isEqualToString:@"tab"] ) {
[self runScript:iTermLegacyNewTabDefault handler:handlerName parameters:passParameters];
}
}
//iTermVersion is not set to "legacy" using applescripts Configured for Stable
if( [iTermVersionPref isEqualToString:@"stable"]) {

//run the applescript that works with iTerm Stable
//if we are running in a new iTerm "Stable" Window
if ( [terminalWindow isEqualToString:@"new"] ) {
[self runScript:iTermStableNewWindow handler:handlerName parameters:passParameters];
Expand All @@ -502,7 +524,7 @@ - (void) openHost:(NSMenuItem *) sender {
}
//we are using the default action of shuttle... The active window in a new tab
if ( [terminalWindow isEqualToString:@"tab"] ) {
[self runScript:iTermStableNewTabDefault handler:handlerName parameters:passParameters];
[self runScript:iTermStableNewTabDefault handler:handlerName parameters:passParameters];
}
}
//iTermVersion is not set to "stable" using applescripts Configured for Nightly
Expand Down
4 changes: 2 additions & 2 deletions Shuttle/Shuttle-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.6</string>
<string>1.2.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.2.6</string>
<string>1.2.7</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Shuttle/apple-scpt/iTerm2-nightly-current-window.scpt
Binary file not shown.
Binary file modified Shuttle/apple-scpt/iTerm2-nightly-new-tab-default.scpt
Binary file not shown.
Binary file modified Shuttle/apple-scpt/iTerm2-nightly-new-window.scpt
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Shuttle/apple-scpt/iTerm2-stable-new-window.scpt
Binary file not shown.
7 changes: 7 additions & 0 deletions apple-scripts/compile-iTermLegacy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
echo "compiling applescripts for iTerm Legacy..."
osacompile -o ~/Git/shuttle/Shuttle/apple-scpt/iTerm-legacy-new-window.scpt -x ~/Git/shuttle/apple-scripts/iTermlegacy/iTerm-legacy-new-window.applescript
osacompile -o ~/Git/shuttle/Shuttle/apple-scpt/iTerm-legacy-current-window.scpt -x ~/Git/shuttle/apple-scripts/iTermlegacy/iTerm-legacy-current-window.applescript
osacompile -o ~/Git/shuttle/Shuttle/apple-scpt/iTerm-legacy-new-tab-default.scpt -x ~/Git/shuttle/apple-scripts/iTermlegacy/iTerm-legacy-new-tab-default.applescript


6 changes: 3 additions & 3 deletions apple-scripts/compile-iTermStable.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
echo "compiling applescripts for iTerm Stable..."
osacompile -o ~/Git/shuttle/Shuttle/apple-scpt/iTerm-stable-new-window.scpt -x ~/Git/shuttle/apple-scripts/iTermStable/iTerm-stable-new-window.applescript
osacompile -o ~/Git/shuttle/Shuttle/apple-scpt/iTerm-stable-current-window.scpt -x ~/Git/shuttle/apple-scripts/iTermStable/iTerm-stable-current-window.applescript
osacompile -o ~/Git/shuttle/Shuttle/apple-scpt/iTerm-stable-new-tab-default.scpt -x ~/Git/shuttle/apple-scripts/iTermStable/iTerm-stable-new-tab-default.applescript
osacompile -o ~/Git/shuttle/Shuttle/apple-scpt/iTerm2-stable-new-window.scpt -x ~/Git/shuttle/apple-scripts/iTermStable/iTerm2-stable-new-window.applescript
osacompile -o ~/Git/shuttle/Shuttle/apple-scpt/iTerm2-stable-current-window.scpt -x ~/Git/shuttle/apple-scripts/iTermStable/iTerm2-stable-current-window.applescript
osacompile -o ~/Git/shuttle/Shuttle/apple-scpt/iTerm2-stable-new-tab-default.scpt -x ~/Git/shuttle/apple-scripts/iTermStable/iTerm2-stable-new-tab-default.applescript


23 changes: 23 additions & 0 deletions apple-scripts/iTermStable/iTerm2-stable-current-window.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--for testing uncomment the "on run" block
--on run
-- set argsCmd to "ps aux | grep [s]sh"
-- scriptRun(argsCmd)
--end run

on scriptRun(argsCmd)
set withCmd to (argsCmd)
CommandRun(withCmd)
end scriptRun

on CommandRun(withCmd)
tell application "iTerm"
reopen
activate
tell the current window
tell the current session
--set name to theTitle
write text withCmd
end tell
end tell
end tell
end CommandRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
--for testing uncomment the "on run" block
--on run
-- set argsCmd to "ps aux | grep xcode"
-- set argsTheme to "Homebrew"
-- set argsTitle to "Custom title"
-- scriptRun(argsCmd, argsTheme, argsTitle)
--end run

on scriptRun(argsCmd, argsTheme, argsTitle)
set withCmd to (argsCmd)
set withTheme to (argsTheme)
set theTitle to (argsTitle)
CommandRun(withCmd, withTheme, theTitle)
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
else
--assume that iTerm is open and open a new tab
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
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
end try
end if
end tell
end CommandRun
39 changes: 39 additions & 0 deletions apple-scripts/iTermStable/iTerm2-stable-new-window.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--for testing uncomment the "on run" block
--on run
-- set argsCmd to "ps aux | grep [s]sh"
-- set argsTheme to "Homebrew"
-- set argsTitle to "Custom title"
-- scriptRun(argsCmd, argsTheme, argsTitle)
--end run

on scriptRun(argsCmd, argsTheme, argsTitle)
set withCmd to (argsCmd)
set withTheme to (argsTheme)
set theTitle to (argsTitle)
CommandRun(withCmd, withTheme, theTitle)
end scriptRun

on CommandRun(withCmd, withTheme, theTitle)
tell application "iTerm"
if it is not running then
activate
delay 0.2
try
close first window
end try
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
write text withCmd
end tell
end tell
end tell
end CommandRun