# Mac OS X Terminal TabName script

A simple set of functions that can be used in bash to adjust the tab names or create new tabs in Mac OS X's Terminal application. The syntax is just
```sh
tabname "<new name of current tab>"
```
or
```sh
new_tab "<new name of tab>" "<command to run>"
```

The original code was posted on
[Original Stackoverflow Article](http://stackoverflow.com/questions/7171725/open-new-terminal-tab-from-command-line-mac-os-x)

```sh
## add to the end of ~/.profile or ~/.bash_profile
tabname() {
	printf "\e]1;$1\a"
}

new_tab() {
  TAB_NAME=$1
  COMMAND=$2
  osascript \
    -e "tell application \"Terminal\"" \
    -e "tell application \"System Events\" to keystroke \"t\" using {command down}" \
    -e "do script \"printf '\\\e]1;$TAB_NAME\\\a'; $COMMAND\" in front window" \
    -e "end tell" > /dev/null
}
```
