Skip to content

Instantly share code, notes, and snippets.

@swdunlop
Last active March 27, 2018 19:12
Show Gist options
  • Save swdunlop/6908ccfb3464e46262cecdc69d5b953c to your computer and use it in GitHub Desktop.
Save swdunlop/6908ccfb3464e46262cecdc69d5b953c to your computer and use it in GitHub Desktop.
Split the Current iTerm2 Session to Run a Command
#!/usr/bin/osascript
on run argv
tell application "iTerm2"
tell current session of current window
set view to split horizontally with default profile command "sh -c " & (quoted form of item 1 of argv)
select view
end tell
end tell
end run
@swdunlop
Copy link
Author

swdunlop commented Mar 27, 2018

I have seen variations of this script elsewhere involving writing to the session, which can result in various forms of derp. It's easier to just provide the command to iTerm2 when you create the new view. I use this for things like iterm ~/bin/fzf-notes, which uses fzf to launch an editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment