Created
November 23, 2012 09:34
-
-
Save kikaigyo/4134754 to your computer and use it in GitHub Desktop.
"情報を見る"をターミナルから開くスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
初めまして。.app(パッケージ)に対して実行するとエラーになってしまいました。
パッケージはターミナルで見るとディレクトリ(folder)ですが、
アップルスクリプトではfileとして扱わないといけないようです。
スクリプトでどうすればパッケージを区別できるのかは知りません。
良い手はありますでしょうか。