Skip to content

Instantly share code, notes, and snippets.

@kikaigyo
Created November 23, 2012 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikaigyo/4134754 to your computer and use it in GitHub Desktop.
Save kikaigyo/4134754 to your computer and use it in GitHub Desktop.
"情報を見る"をターミナルから開くスクリプト
#!/bin/sh
# This script opens the Finder's "Get Info" window
# for the file or folder specified as a command-line argument.
# http://tukaikta.blog135.fc2.com/blog-entry-240.html
scriptname=`basename $0`
if [ $# -lt 1 ]; then
echo "Usage: $scriptname file_or_folder"
exit
fi
path=$1
if [ ! -e $path ]; then
echo "$scriptname: $path: No such file or directory"
exit
fi
case $path in
/*) fullpath=$path ;;
~*) fullpath=$path ;;
*) fullpath=`pwd`/$path ;;
esac
if [ -d $fullpath ]; then
file_or_folder="folder"
else
file_or_folder="file"
fi
/usr/bin/osascript > /dev/null <<EOT
tell application "Finder"
set macpath to POSIX file "$fullpath" as text
open information window of $file_or_folder macpath
end tell
EOT
@hisaya
Copy link

hisaya commented Aug 9, 2013

初めまして。.app(パッケージ)に対して実行するとエラーになってしまいました。
パッケージはターミナルで見るとディレクトリ(folder)ですが、
アップルスクリプトではfileとして扱わないといけないようです。
スクリプトでどうすればパッケージを区別できるのかは知りません。
良い手はありますでしょうか。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment