iTerm helper using AppleScript.
build env:
- macOS: Sierra 10.12.6
- iTerm2: Build 3.1.5
$ ./demo/run 2 4
Compiling /Users/user/git/iTerm-launcher/app/lib/iterm.applescript...
v2.0
-- Load iTerm script.
tell application "Finder" to set binPath to POSIX path of (container of (path to me) as text) & "app/bin/"
set iterm to load script file (currentPath & "iterm.scpt")
-- Use iTerm script.
set ITERM_WINDOW to newWindow() of iterm -- row, column
-- show version
log VERSION of iterm
-- Split pane
splitPane(ITERM_WINDOW, 2, 2) of iterm
-- run command to current pane
runCmd(ITERM_WINDOW, "echo 'This is active pane current'") of iterm
-- run command to all panes
runCmdAllPanes(ITERM_WINDOW, "echo 'all'") of iterm
-- run command to specific pane
runCmdPane(ITERM_WINDOW, 2, "echo 'This is second pane'") of iterm
-- run commands to each pane
runCmdEachPanes(ITERM_WINDOW, [¬
"echo '1'",¬
"echo '2'",¬
"echo '3'"¬
]) of iterm
-- send keystroke
sendKeystroke("CMD-OPT-i") of iterm
Example:
tell application "Finder" to set binPath to POSIX path of (container of (path to me) as text) & "app/bin/"
set iterm to load script file (currentPath & "iterm.scpt")
set ITERM_WINDOW to newWindow() of iterm
Example:
tell application "Finder" to set binPath to POSIX path of (container of (path to me) as text) & "app/bin/"
set iterm to load script file (currentPath & "iterm.scpt")
set ITERM_WINDOW to newWindow() of iterm
splitPane(ITERM_WINDOW, 2, 2) of iterm
Example:
tell application "Finder" to set binPath to POSIX path of (container of (path to me) as text) & "app/bin/"
set iterm to load script file (currentPath & "iterm.scpt")
set ITERM_WINDOW to newWindow() of iterm
splitPane(ITERM_WINDOW, 2, 2) of iterm
runCmdAllPanes(ITERM_WINDOW, "ls -al") of iterm
Example:
tell application "Finder" to set binPath to POSIX path of (container of (path to me) as text) & "app/bin/"
set iterm to load script file (currentPath & "iterm.scpt")
set ITERM_WINDOW to newWindow() of iterm
splitPane(ITERM_WINDOW, 2, 2) of iterm
runCmd(ITERM_WINDOW, "echo 'This is current active pane'") of iterm
Example:
tell application "Finder" to set binPath to POSIX path of (container of (path to me) as text) & "app/bin/"
set iterm to load script file (currentPath & "iterm.scpt")
set ITERM_WINDOW to newWindow() of iterm
splitPane(ITERM_WINDOW, 2, 2) of iterm
runCmdPane(ITERM_WINDOW, 2, "echo 'This is second pane'") of iterm
Example:
tell application "Finder" to set binPath to POSIX path of (container of (path to me) as text) & "app/bin/"
set iterm to load script file (currentPath & "iterm.scpt")
set ITERM_WINDOW to newWindow() of iterm
splitPane(ITERM_WINDOW, 2, 2) of iterm
runCmdEachPanes(ITERM_WINDOW, [¬
"ls -al",¬
"htop",¬
"ps -ef | grep java"¬
]) of iterm
Example:
tell application "Finder" to set binPath to POSIX path of (container of (path to me) as text) & "app/bin/"
set iterm to load script file (currentPath & "iterm.scpt")
set ITERM_WINDOW to newWindow() of iterm
splitPane(ITERM_WINDOW, 2, 2) of iterm
sendKeystroke("CMD-OPT-i") of iterm