Skip to content

Instantly share code, notes, and snippets.

@hex2010
Created September 27, 2016 04:33
Show Gist options
  • Save hex2010/5dff6e0af07b601706ea5250f50c0a74 to your computer and use it in GitHub Desktop.
Save hex2010/5dff6e0af07b601706ea5250f50c0a74 to your computer and use it in GitHub Desktop.
Run command in new window of iTerm2
#!/bin/bash
read -r -d '' script <<'EOF'
on run argv
tell application "iTerm"
activate
set newWindow to (create window with default profile)
tell current session of newWindow
set args to ""
repeat with arg in argv
set args to args & arg & " "
end repeat
write text args
end tell
end tell
end run
EOF
echo "$script" | osascript ``-'' $@
@hex2010
Copy link
Author

hex2010 commented Sep 27, 2016

iterm.sh "cd /usr && ls"

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