Created
March 12, 2017 14:38
-
-
Save sebcode/2ae6ecd6c638b7b0e9175024b03c22a0 to your computer and use it in GitHub Desktop.
JXA: Programmatically open a new iTerm tab with a specified command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript -l JavaScript | |
// Open a new iTerm tab with a specified command. | |
// Usage example: ./openTermCommand.js '/usr/local/bin/vim /tmp/test.txt' | |
function run(argv) { | |
const iTerm = Application('iTerm') | |
iTerm.includeStandardAdditions = true | |
iTerm.activate() | |
const command = argv[0] | |
let win = iTerm.currentWindow() | |
if (win == null) { | |
win = iTerm.createWindowWithDefaultProfile({ command }) | |
} else { | |
win.createTabWithDefaultProfile({ command }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment