Create a gist now

Instantly share code, notes, and snippets.

OSX Terminal – Tab and window shortcuts
function tabname {
# Will use current dir name if called without arg.
printf "\e]1;${1-$(basename `pwd`)}\a"
}
function winname {
# Will use current dir name if called without arg.
printf "\e]2;${1-$(basename `pwd`)}\a"
}
function tab {
# Will cd into current dir if called without arg.
osascript -e 'tell application "Terminal"' \
-e 'tell application "System Events" to keystroke "t" using {command down}' \
-e "do script \"cd `pwd` && cd ${1-.} && tabname && clear\" in front window" \
-e 'end tell' > /dev/null
}
alias t='tab'
alias tn='tabname'
alias wn='winname'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment