Skip to content

Instantly share code, notes, and snippets.

@napisani
Created February 22, 2017 03:17
Show Gist options
  • Save napisani/bbc1a815f65d3c98757f3c66c8eac476 to your computer and use it in GitHub Desktop.
Save napisani/bbc1a815f65d3c98757f3c66c8eac476 to your computer and use it in GitHub Desktop.
fix spotlight index of cask apps by creating alias files
#!/bin/bash
mdfind "kMDItemKind == 'Alias'" -onlyin /Applications/ | while read x ; do rm -f "$x" ; done
find /usr/local/Caskroom -name "*.app" | grep -E "/latest/[^/]*.app$" | while read x ; do
echo "$x"
SHORT=`echo $x | sed s/.app//g | sed 's/.*\/latest\///g' | sed 's/ /_/g' | awk '{print tolower($0)}' `
echo "$SHORT"
osascript<<EOF
set $SHORT to POSIX file "$x"
set applications_folder to POSIX file "/Applications"
tell application "Finder"
make alias file to $SHORT at applications_folder
end tell
EOF
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment