Skip to content

Instantly share code, notes, and snippets.

@joxl
Created March 26, 2015 21:12
Show Gist options
  • Save joxl/775c36e37d64f70626af to your computer and use it in GitHub Desktop.
Save joxl/775c36e37d64f70626af to your computer and use it in GitHub Desktop.
do-in-new-term.sh
#!/bin/bash
TERM_APP="iTerm" # change to your prefered terminal app
here=$(printf '%q' "$(pwd)") # quote it
command="$@"
osascript -e "$(cat <<EOF
on run argv
activate application "$TERM_APP"
tell application "System Events" to keystroke "n" using command down
if (count of argv) is not 0 then
tell application "iTerm"
tell session -1 of current terminal
repeat with i from 1 to (count argv)
write text "" & (item i of argv) & ""
end repeat
end tell
end tell
end if
end run
EOF)" "cd $here" "$command"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment