-
-
Save jasalt/abcf2d53183399f85f29 to your computer and use it in GitHub Desktop.
Open new Terminal tabs from the command line
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
#!/bin/bash | |
# | |
# Open new Terminal tabs from the command line to currently running ITerm2 | |
# session | |
# | |
# Author: Justin Hileman (http://justinhileman.com) | |
# Modified by: Jarkko Saltiola (http://saltio.la) | |
# | |
# Installation: | |
# Add this file path | |
# | |
# Usage: | |
# iterm Opens the current directory in a new tab | |
# iterm [PATH] Open PATH in a new tab | |
# iterm [CMD] Open a new tab and execute CMD | |
# iterm [PATH] [CMD] ... You can prob'ly guess | |
CMD="" | |
CDTO="$PWD" | |
ARGS="$@" | |
if [ -d "$1" ]; then | |
CDTO=`cd "$1"; pwd` | |
ARGS="${@:2}" | |
fi | |
if [ -n "$ARGS" ]; then | |
CMD="; $ARGS" | |
fi | |
osascript &>/dev/null <<EOF | |
tell application "iTerm" | |
tell current terminal | |
launch session "Default Session" | |
tell the last session | |
write text "cd \"$CDTO\"$CMD" | |
write text "clear" | |
end tell | |
end tell | |
end tell | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment