Last active
August 29, 2015 14:07
-
-
Save curiositycasualty/c18cb01359f7756cf03c to your computer and use it in GitHub Desktop.
iTerm/OSA functions
This file contains 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
# use applescript to activate an application by name | |
function activate() { | |
app=$1; | |
echo "tell application \"$app\" to activate" | osascript; | |
} | |
# use applescript open a new iTerm (horizontal) pane with a given command to run as an argument | |
function new_hpane() { | |
cmd=$1; | |
activate "iTerm"; | |
echo "tell application \"System Events\" to tell process \"iTerm\" to keystroke \"d\" using {command down, shift down}\ntell application \"System Events\" to tell process \"iTerm\" to keystroke \"$cmd\"\ntell application \"System Events\" to tell process \"iTerm\" to key code 52" | osascript; | |
} | |
# use applescript open a new iTerm (vertical) pane with a given command to run as an argument | |
function new_vpane() { | |
cmd=$1; | |
activate "iTerm"; | |
echo "tell application \"System Events\" to tell process \"iTerm\" to keystroke \"d\" using command down\ntell application \"System Events\" to tell process \"iTerm\" to keystroke \"$cmd\"\ntell application \"System Events\" to tell process \"iTerm\" to key code 52" | osascript; | |
} | |
# default to new horizontal iTerm panes | |
alias new_pane="new_hpane" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment