Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Select files in Finder from Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Select files in Finder from Terminal
Authored by: FangVT on May 24, '06 11:22:33AM

Wow, that's a lot of extraneous shell code.

The whole loop to build the arguments variable is not needed, just use $* or $@.

So the function then becomes:

function showinfinder() {
thepath=`pwd`;
echo "/path/to/the/script/FinderSelect.scpt" \
"Current_path:$thepath" "$*" | xargs osascript;
}

Now let's not waste time setting up a temporary variable to hold the current directory.

So the function now becomes:

function showinfinder() {
echo "/path/to/the/script/FinderSelect.scpt" \
"Current_path:`pwd`" "$*" | xargs osascript;
}

I'm not really familiar with xargs and I can only glean so much from a quick skim of the man page, but I think you don't need it.

So the final function might just need to be:

function showinfinder() {
osascript "/path/to/the/script/FinderSelect.scpt" \
"Current_path:`pwd`" "$*"
}



[ Reply to This | # ]
Select files in Finder from Terminal
Authored by: masjones on May 24, '06 12:00:33PM

Wouldn't it be easier to use LaunchBar or Butler or even the Finder itself to find a specific file? Especially since oyu know its name?

I do not ever use the Terminal so maybe I am missing something.

Mj



[ Reply to This | # ]
Select files in Finder from Terminal
Authored by: mistersquid on May 25, '06 06:20:25AM
I do not ever use the Terminal so maybe I am missing something.

Not to be harsh but, yeah, you definitely are missing something. In particular, there are times when one is working at the command line and wants to open selected files in the GUI without having to navigate using the GUI.



[ Reply to This | # ]
Select files in Finder from Terminal
Authored by: rwmitchell on May 24, '06 01:32:16PM

For the tcsh, I created an alias:

alias sf 'osascript ~/bin/selectfinder.scpt Current_path:`pwd` $*'

which seems to work for me. (note that my alias has the path to the script hardcode, so adjust that for your environment)


to the person wondering why you'd want to do this instead of just using the finder, there are some situations where it is easier to wildcard a selection than it is select in the finder. A case where the middle of the filename has some uniq attribute that you want to select for. To the rest of us command line unix diehards, it just feels more natural :-)



[ Reply to This | # ]
Select files in Finder from Terminal
Authored by: Lutin on May 25, '06 05:12:17AM
Thank you for the improvement.

function showinfinder() {
   osascript "/path/to/FinderSelect.scpt""Current_path:`pwd`" "$@"
}
works for me (but $* didn't).

[ Reply to This | # ]