Created
April 18, 2015 23:35
-
-
Save jasontbradshaw/f4a2f4ca6f874a3e4745 to your computer and use it in GitHub Desktop.
isostick ISO Selector Script
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
#!/usr/bin/env sh | |
isofile='./config/iso_filename.txt' | |
isofile_pretty="$(basename "${isofile}")" | |
iso="${1}" | |
# if the user supplied an argument, write it to the file, otherwise offer them a | |
# choice of all present ISO files | |
if [ -n "${iso}" ]; then | |
echo "${iso}" > "${isofile}" | |
echo "'${iso}' written to ${isofile_pretty}" | |
else | |
# list all ISO files recursively, keeping their paths and ignoring hidden | |
isos=($(find . -not -path '*/\.*' -name '*.iso*' | sed 's|^\./||' | sort)) | |
PS3="Select an ISO to write to ${isofile_pretty}: " | |
COLUMNS=1 # hack to force single-column select output | |
select iso in "${isos[@]}"; do | |
echo "${iso}" > "${isofile}" | |
echo "'${iso}' written to ${isofile_pretty}" | |
exit 0 | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment