Created
July 15, 2014 06:56
-
-
Save anonymous/f16a46c327a14ec8a5b5 to your computer and use it in GitHub Desktop.
Create a new tab in Terminal using bash and AppleScript.
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
new-tab () | |
{ | |
if [ "$#" -eq 1 ]; then | |
COMMAND="$1"; | |
osascript -e "tell application \"Terminal\"" -e "tell application \"System Events\" to keystroke \"t\" using {command down}" -e "do script \"clear && $COMMAND\" in front window" -e "end tell" > /dev/null; | |
else | |
if [ "$#" -eq 2 ]; then | |
COMMAND="$1"; | |
TAB_NAME="$2"; | |
osascript -e "tell application \"Terminal\"" -e "tell application \"System Events\" to keystroke \"t\" using {command down}" -e "do script \"clear && name-tab '$TAB_NAME' && $COMMAND\" in front window" -e "end tell" > /dev/null; | |
else | |
echo -e "usage: $FUNCNAME command [tab_name]\n"; | |
fi; | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment