Saturday, 24 September 2011

Automatically cd to active Finder directory in new Terminal window

There exist small apps that will open a new Terminal window or tab and automatically cd to the directory of the active Finder window. This hint describes a way to have the Terminal always cd to the directory of the active Finder window whenever you open a new Terminal window or tab -- without the use of an app or any other third-party solution.

In other words, whenever you open a Terminal window or tab, if there is an open Finder window, the Terminal will start in the directory shown in the Finder window.

To make this happen, all you need to do is add the following line somewhere in your .bash_profile file in your home directory:
 cd `osascript -e 'tell application "Finder" to if window 1 exists then if target of window 1 as string is not ":" then get POSIX path of (t ...


Add to digg Add to Reddit Add to Slashdot Email this Article Add to StumbleUpon

Source: http://feeds.macosxhints.com/click.phdo?i=48fea970a530ed22bf967df324462e13

iwork 09 mac store refurbished apple news apple breaking news

No comments:

Post a Comment