I have just created and uploaded a GitHub Gist GitHub Gist which may help you out.
The main functionality is:
function get_apps_folder () {
mdfind -0 -onlyin / \
'kMDItemKind=="Application" && kMDItemDisplayName="'"${1:-TextEdit}"'"' \
| xargs -0 -I{} dirname {}
}
function open_apps_folder () {
open $(get_apps_folder "$1")
}
You could take that and add the two functions to your ~/.bash_profile
and they would be available for any interactive shell sessions you are using. (And yes, getting around mixed and embedded single and double quotes can be messy.) :-)
But, to give a better explanation, the main part is:
mdfind -0 -onlyin / 'kMDItemKind=="Application" && kMDItemDisplayName="VMware Fusion"' | xargs -0 -I{} open {}
The -onlyin /path
limits the search to just the root volume, otherwise any “Spotlight-searchable” volume attached will most likely be searched as well, including Time Machine, which can get unwieldy and/or verbose, hence using -onlyin /
.
In the Gist, each line output by mdfind
is fed to xargs
which calls open
on what is passed to it. Note that there is no particularly robust checking of what is passed to xargs
(ie. it is assuming it is getting a directory).
mdfind
and mdls
can be pretty handy for things like this, although they can take a little getting used to. I usually use mdls /path/to/file
to get an idea of what metadata that type of file has. I can then take those keys and values to search using mdfind
. You can find a lot of pages, examples and documentation out there, BTW.
vmrun
entered in Terminal should control an arbitrary VM and VMware Fusion or even several different versions are installed in arbitrary folders (which usually isn't the case because the default installation folder is /Applications/). – klanomath Sep 1 '15 at 7:52<some-command>
or identifying the true path of/VMware\ Fusion.app/
? – voices Sep 1 '15 at 8:28