PDA

View Full Version : Get Terminal drawer to auto "cd" when PF changes directories


dgharrison
Jul 10, 2005, 08:02 PM
Is there any way i can get the terminal draw to automatically cd to any directory i move to in browser window.

Alternativly is it possible to get a right click menu item that cds the termial draw to a folder?

neilio
Jul 10, 2005, 08:41 PM
There's this hint on MacOSXHints.com (http://www.macosxhints.com/article.php?story=20050413201826795) that looks promising. I seem to remember setting this up a while ago and it seemed to work okay, though it was quite slow.

That, unfortunately, is the main reason why we haven't implemented this yet. The terminal framework we're using doesn't take piped commands very well (as far as we know) so we'd be forced to use a similar process as the hint above outlines.

This might be something we'll try to implement for Path Finder 4.1, but it won't make it into the 4.0 release.

(note: we have improved PF4 so that when you open a new terminal drawer or window, you're automatically cd'ed into the current directory in the file browser.)

dgharrison
Jul 11, 2005, 07:48 PM
do you happen to know how to fix this error?:

2005-07-12 12:41:06.612 osascript[723] CFLog (21): Cannot find executable for CFBundle 0x3546c0 </Users/dan/Library/ScriptingAdditions/Contents> (not loaded)

i get it when i try and run pff or pft

dberstein
Jun 19, 2007, 04:30 PM
I faced similar problems with the pff/pft implementations I found in other sites. I too the challenge, and after much research, trial and error, here I present my own versions of pff/pft:


File pff.scpt:
(*
Name:
pff.scpt
Description:
Script to obtain Path Finder's front window/tab current path.
Usage:
CURRENT_IN_PF=$(osascript /path/to/this/script)
Example (bash):
cd $(osascript ~/pff.scpt)
See Also:
pft.scp
Author:
Daniel Berstein <daniel@basegeo.com>
Last Modified:
2007-06-20
*)
tell application "Path Finder"
(* Find fron window/tab *)
set the window_list to the finder windows
set the front_window to item 1 of window_list
set the containee to the target of the front_window
set the_path to POSIX path of the containee

(* Return the path *)
return the_path
end tell

File pft.scpt:

(*
Name:
pft.scpt
Description:
Script to command the front Path Finder window/tab to a given path.
If no Path Finder window is found, a new one is opened. Most useful for syncronizing
the PWD of a terminal session with Path Finder.
Usage:
osascript /path/to/this/script /new/path/to/use/in/path/finder
Example (bash):
osascript ~/pft.scpt $(pwd)
See Also:
pff.scpt
Author:
Daniel Berstein <daniel@basegeo.com>
Last Modified:
2007-06-20
*)
on run the_path
tell application "Path Finder"
(* Find front window/tab *)
activate
set the window_list to the finder windows
if (count of window_list) is greater than 0 then
set the front_window to item 1 of window_list
set the containee to the target of the front_window
(*
When the new path is not directly reacheable from the current view,
like when traversing sibling directories, PF cannot make the switch in
a single step. The workaround is to repeat the procedure twice.
*)
set path_found to false
set max_tries to 2
repeat until path_found or max_tries is equal to 0
(* Select in PF the new path *)
select the_path
if (count of selection) is not 0 then
(* Using selection so we can get an fsItem *)
set selection_list to selection
repeat with the_item in selection_list
set target of the item 1 of the finder windows to the_item
end repeat
set path_found to true
else
set max_tries to max_tries - 1
end if
end repeat
(* If PF cannot find/reach the location (ie. /etc), inform user *)
if not path_found then
display dialog "Path Finder cannot reach " & the_path
activate
end if
else
(* Open a new Path Finder window if none is found *)
PFOpen the_path
end if
end tell
end run



To use them I put both files under ~/bin and added the following aliases in my .bash_profile:

# Synchronize Path Finder to PWD
alias pft='osascript ~/bin/pft.scpt "$(pwd)"'
# Set PWD to current PWD
alias pff='cd "$(osascript ~/bin/pff.scpt)"'


After sourcing (source ~/.bash_profile) you can use them from PF's built-in terminal, iTerm or even Terminal.app :)

Hope it helps.

jackmon13
Oct 24, 2008, 04:47 PM
I know this is not exactly what was requested, but in case it's helpful, I always just click the drawer button twice so that the drawer closes and reopens. When it reopens it's cd'd to the directory selected in the UI above.

Quine
Nov 18, 2008, 10:00 PM
hey, i noticed this topic is quite old, but i was using dolphin recently, and I was wondering if pathfinder might have implemented this yet? that'd be a really big incentive for me to start using it

travis134
Nov 24, 2008, 02:56 AM
Mine does not unless I close/reopen the terminal drawer. I would love this feature as well :)