View Single Post
cptkrf

 
cptkrf's Avatar
 
Member Since: Dec 08, 2009
Location: The same as Sheldon Cooper - East Texas
Posts: 453
cptkrf is a jewel in the roughcptkrf is a jewel in the rough
Mac Specs: iMac 2014 i5 5k 32gb 1tb fusion, second TB display, 2014 MBA

cptkrf is offline
Save the following script (and be sure to chmod it to 755). Run it and it will open a new tab(s) in the same folder.




#!/bin/sh

# Make a new OS X Terminal tab with the current working directory.

if [ $# -ne 1 ]; then
PATHDIR=`pwd`
else
PATHDIR=$1
fi

/usr/bin/osascript <<EOF
activate application "Terminal"
tell application "System Events"
keystroke "t" using {command down}
end tell
tell application "Terminal"
repeat with win in windows
try
if get frontmost of win is true then
do script "cd $PATHDIR; clear" in (selected tab of win)
end if
end try
end repeat
end tell
EOF
clear
QUOTE Thanks