Skip to content

Instantly share code, notes, and snippets.

@lepture
Created October 23, 2014 06:52
Show Gist options
  • Select an option

  • Save lepture/7874bac8bb5746cbaa2d to your computer and use it in GitHub Desktop.

Select an option

Save lepture/7874bac8bb5746cbaa2d to your computer and use it in GitHub Desktop.
replace icon for mac application and folder
#!/bin/bash
BIN=/Applications/Xcode.app/Contents/Developer/Tools/
DeRez=$BIN/DeRez
Rez=$BIN/Rez
iconify() {
ICON="$1"; FOLDER="$2"
if [[ -f $ICON && -d $FOLDER ]]; then
TMP_DIR=$(mktemp -d -t iconify)
cp "$ICON" "$TMP_DIR/icon.icns"
sips -i "$TMP_DIR/icon.icns"
$DeRez -only icns "$TMP_DIR/icon.icns" > "$TMP_DIR/icon.rsrc"
$Rez -append "$TMP_DIR/icon.rsrc" -o "$FOLDER"/$'Icon\r'
SetFile -a C "$FOLDER"
SetFile -a V "$FOLDER"/$'Icon\r'
else
echo "File or folder not found"
fi
}
if [[ "$1" && "$2" ]]; then
iconify "$1" "$2"
else
echo "Usage: iconify example.icns /path/to/folder"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment