help with termianal

Joined
Jan 30, 2010
Messages
2
Reaction score
0
Points
1
Hello guys, im new at forum and im having a problem with terminals in general.

Ive been looking it a while and i hope to get the anwser here.

What I want is to find a way to open a new tab in a terminal and keep at the same directory of the current tab. ( Id like to use the classic terminal or terminator. dont like iTerm )

if anyone knows how to do it or a link that can guide me ill appreciate.

thanks in advanced!
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
I don't know of any automatic way to do that within Terminal.

In preferences you can run a script, but as far as I can recall recall, you can't peak at your other terminal sessions to know where they are.

I'd just do a 'pwd' in the current terminal window. Copy the result path. Use 'cd' and paste the copied path to the end of it, with a space between them.

You could likely make an elaborate method of copying the current path of the current window to a file and reading that upon login if it exists. That gets into changing the things like the cd command and beyond where I want to go.
 
Joined
Dec 8, 2009
Messages
453
Reaction score
10
Points
18
Location
The same as Sheldon Cooper - East Texas
Your Mac's Specs
iMac 2014 i5 5k 32gb 1tb fusion, second TB display, 2014 MBA
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
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top