アイコンに関するこの問題は、しばらくの間私を悩ませてきました。基本的な解決策は、基本的にファイルを完全に無視することでした。私は視覚的な人間であり、プロジェクトのクールなアイコンを作成するのに時間を無駄にすることを楽しんでいるため、これを拒否しました。
注:動作するように最善を尽くしましたが、保証はできませんので、データのコピーを試してください。そうは言っても、これがこの問題に対する私の解決策でした。
基本的に、Macアイコンの問題に対処するために3つのスクリプトを作成しました。
- repoMacPrepare.sh
- repoMacRestore.sh
- gitAliasScript.sh
これらの3つのスクリプトは、gitまたはsvnが受け入れて保存できる形式でmacアイコンを追加するために使用されます。最初のスクリプトは、ディレクトリ内のアイコンベースのファイルとファイル内のカスタムアイコン形式を検索するリポジトリを準備します。次に、それらをそれぞれのパス内に.jdIcndまたは.jdIcnf(フォルダーのディレクトリfの場合はd)として格納します。
2番目のスクリプトでは、.jdIcndファイルと.jdIcnfファイルを検索することで、Mac上でスクリプトを復活させることができます。
最後のスクリプトは、プロセスを自動化する方法を示しています。.bashrcファイルのgitAliasScript.shスクリプトを参照するgitのエイリアスを使用しています。今、私はgitに切り替えました(私がした最良のこと)ので、スクリプトはgitで表示されますが、基本はsvnでも同じです。これが、チェックインプロセスまたはチェックアウトプロセスの一部としてアイコンを失うことのないバージョニングシステムを使用しているMacユーザーに役立つことを願っています。また、アイコンはドットプレフィックス付きのバイナリファイルとして保存されているため、このスクリプトを使用していない場合でも問題は発生しないことに注意してください。ああ、そうだね...
ファイル:repoMacPrepare.sh
#! /bin/bash
#
# Author: Joshua Demori
# Email: jdemori@jrdfamily.com
#
# This script is used to prepare a repository
# to still record the Icons used on a mac for files or directories
#
# First
# DeRez Icon^M > .IconCntrlR
# (hit control-v then enter to get the carriage return vi)
#
# Store in Repository
# then to bring back
# Rez -append IconCopy -o Icon
# # may need to set the Folders Icon Info
# SetFile -a C /Path/To/Custom/Folder/With/Icon/
#
# if I need to SetFile the folder I can do this 2 ways
# a main file which has all this data at base of repository (bad)
# as it finds those files it does the folder below it
#
#
#=======================================================#
# Defines
readonly VERSION=1.00
#=======================================================#
# Variables
varVerbose=false
#=======================================================#
# Functions
setupDirIcon () {
DeRez "${file}"/Icon
> "${file}"/.Icon.jdIcnd
if [ $varVerbose == true ]; then
echo Adding Icon File: "$file"/.Icon.jdIcnd
fi
}
setupFileIcon () {
base=`basename "$file"`
path=`dirname "$file"`
DeRez "$file" > "${path}"/."${base}".jdIcnf
if [ $varVerbose == true ]; then
echo Adding Icon File: "$file"/."${base}".jdIcnf
fi
}
# cmd line functions
function funcOptionVersion {
echo "Reposiotry Mac Icon Preperation Script Version: $VERSION"
exit 0
}
function funcOptionHelp {
name=`basename $0`
echo $name Help Screen
echo '-h help'
echo '-v verbose'
echo '-n version'
echo ' '
exit 0
}
function funcOptionVerbose {
varVerbose=true
}
#=======================================================#
# process cmd line arguments
while getopts "vhn" optionName; do
case "$optionName" in
n) funcOptionVersion ;;
h) funcOptionHelp ;;
v) funcOptionVerbose ;;
[?]) printErrorHelpAndExit "$badOptionHelp";;
esac
done
#=======================================================#
#=======================================================#
# Start main portion of script
# ignore . .DS_Store .git folders and files
find . | grep -v ^.$ | grep -v .DS_Store | grep -v .git | grep -v .svn | while read file
do
# does this file have an icon attribute
GetFileInfo -a "$file" | grep C > /dev/null
if [ $? = 0 ]; then
if [ -d "$file" ]; then
setupDirIcon
else
setupFileIcon
fi
fi # end if for icon test
done
# Remove Only the Icon file used by directories
echo Removing Icon File
if [ $varVerbose == true ]; then
find . -name Icon
-print -exec rm {} \;
else
find . -name Icon
-exec rm {} \;
fi
ファイル:repoMacRestore.sh
#! /bin/bash
#
# Author: Joshua Demori
# Email: jdemori@jrdfamily.com
#
# This Script complemnts xxxx by reversing the icons as derez to rez
# then setting the proper file attributes to view the icons
#
# First
# DeRez Icon^M > .IconCntrlR
# (hit control-v then enter to get the carriage return vi)
#
# Store in Repository
# then to bring back
# Rez -append IconCopy -o Icon
# # may need to set the Folders Icon Info
# SetFile -a C /Path/To/Custom/Folder/With/Icon/
#
# if I need to SetFile the folder I can do this 2 ways
# a main file which has all this data at base of repository (bad)
# as it finds those files it does the folder below it
#
#
#=======================================================#
# Defines
readonly VERSION=1.00
#=======================================================#
# Variables
varVerbose=false
#=======================================================#
# Functions
# cmd line functions
function funcOptionVersion {
echo "Repository Mac Icon Restore Script Version: $VERSION"
exit 0
}
function funcOptionHelp {
name=`basename $0`
echo $name Help Screen
echo '-h help'
echo '-v verbose'
echo '-n version'
echo ' '
exit 0
}
function funcOptionVerbose {
varVerbose=true
}
#=======================================================#
# process cmd line arguments
while getopts "vhn" optionName; do
case "$optionName" in
n) funcOptionVersion ;;
h) funcOptionHelp ;;
v) funcOptionVerbose ;;
[?]) printErrorHelpAndExit "$badOptionHelp";;
esac
done
#=======================================================#
#=======================================================#
# Start main portion of script
#=======================================================#
# Go thourgh directories
find . -name *.jdIcnd | while read file
do
# is it a dir - restore dir icon
echo "$file" | grep jdIcnd
if [ $? = 0 ]; then
if [ $varVerbose == true ]; then
echo Fixing Directory Icon: "$file"
fi
path=`dirname "$file"`
Rez "$file" -o "${path}"/Icon
SetFile -a V "${path}"/Icon
SetFile -a C "${path}"
fi
done
# Go thourgh files
# is it a file - restore file icon
find . -name *.jdIcnf | while read file
do
echo "$file" | grep jdIcnf
if [ $? = 0 ]; then
path=`dirname "$file"`
base=`basename "$file"`
origFileName=`echo "$base" | sed 's/\.jdIcnf//'`
origFileName=`echo "${origFileName:1}"`
fileWithPath="${path}"/"${origFileName}"
if [ $varVerbose == true ]; then
echo Restoring File Icon: "$path"
fi
#echo origFileName: "$origFileName"
#echo filesWithPath: "$fileWithPath"
Rez -append "$file" -o "$fileWithPath"
SetFile -a C "$fileWithPath"
fi
done
gitAliasScript.sh
#! /bin/bash
found=false
args=("$@")
for var in "$@"
do
x=`echo $var | grep -ic commit`
if [ $x == 1 ]; then
# prepare icons to be saved
# add them to repository
# at the end git is run
repoMacPrepare.sh
find . -name *.jdIcnd -exec git add {} \;
find . -name *.jdIcnf -exec git add {} \;
found=true
fi
done
#runs git cmd here
cmdPart='git '
cmd=${cmdPart}${@}
$cmd
# finish by bringing back icons
# if commit was called
if [ $found == true ]; then
repoMacRestore.sh
fi
exit 0