Similarly to running open "/Applications/Firefox.app"
, I would like to open the "Get Info" window of /Applications/Firefox.app
using command line.
-
Can you explain your broader workflow? Why do you need to get info from a shell command? Do you need the actual data, or just the window?– benwiggyCommented Jan 8, 2021 at 12:34
Add a comment
|
1 Answer
I don't think you can do this with a shell command, but you can use a shell script to run AppleScript, which can do it. See here:
https://stackoverflow.com/questions/24421803/open-info-window-in-finder-by-applescript
For example:
osascript -e "set aFile to (POSIX file \"/Applications/Firefox.app\") as text" \
-e "tell application \"Finder\" to open information window of file aFile"
If you want to add in your bash or zsh profile:
getfileinfo() {
local FILE="$1"
if [[ -r "${FILE}" ]]; then
osascript <<EOF
set aFile to (POSIX file "$FILE") as alias
tell application "Finder" to open information window of aFile
EOF
fi
}
-
Brilliant indeed, so you can just add something like:
osascript <<EOF set aFile to (POSIX file "$FILE") as alias tell application "Finder" to open information window of aFile EOF
in your dotfiles Commented Jan 8, 2021 at 13:31 -
2@RakibFiha I've changed the condition in the
if
,-f
is always false for applications.– nohillside ♦Commented Jan 8, 2021 at 15:02 -
2@RakibFiha
-f
basically tests for existance of a file, things likeFirefox.app
are always directories. Using-r
works, as would-e
.– nohillside ♦Commented Jan 8, 2021 at 15:51