Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save harrikauhanen/268080 to your computer and use it in GitHub Desktop.
Save harrikauhanen/268080 to your computer and use it in GitHub Desktop.
# Open a new tab on OSX Terminal with the current working dir.
# Optionally, pass the number of tabs as parameter.
#
# Example:
#
# cd /my/very/long/path/and/i/dont/want/to/repeat/myself
# nt 10
#
# You should add this to your ~/.profile
#
function nt {
if [ $# -ne 1 ]; then
TIMES=1
else
TIMES=$1
fi
osascript -e "
repeat $TIMES times
tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down
tell application \"Terminal\" to do script \"cd $PWD; clear;\" in selected tab of the front window
end repeat
" > /dev/null 2>&1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment