Skip to content

Commit

Permalink
Merge pull request #2 from Syntaxheld/feature/find-by-spotlight
Browse files Browse the repository at this point in the history
use spotlight to find installers when no argument is given
  • Loading branch information
jonelo authored Oct 20, 2018
2 parents 457c48f + 3fdb93d commit 83d6095
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions osxapp_vers
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,19 @@ SUPPORTED_OS=$(printf "%s\n" ${SUPPORTED_OS[@]})

if [ $# = 0 ]; then
# No args have been given
# Find any OS X installers in /Applications
FILES=$(ls -ld1 /Applications/Install\ *OS\ X\ *.app 2>/dev/null;\
ls -ld1 /Applications/Install\ macOS\ *.app 2>/dev/null)
# Find any OS X installers known to the Spotlight
FILES=$(
mdfind "kMDItemFSName == 'Install OS X *.app'" 2>/dev/null;\
mdfind "kMDItemFSName == 'Install macOS *.app'" 2>/dev/null;\
)
else
# Use the program arguments as the input
FILES=$(printf "%s\n" $@)
fi

# Error message if there is no installer
if [ -z "$FILES" ]; then
printf "INFO: There is no \"Install *OS X *.app\" and no \"Install macOS *.app\" in /Applications\n"
printf "INFO: There is no \"Install *OS X *.app\" and no \"Install macOS *.app\" known to Spotlight\n"
else
for FILE in $FILES; do
# print the app folder
Expand Down

0 comments on commit 83d6095

Please sign in to comment.