Skip to content

Instantly share code, notes, and snippets.

@jasontbradshaw
Created April 18, 2015 23:35
Show Gist options
  • Save jasontbradshaw/f4a2f4ca6f874a3e4745 to your computer and use it in GitHub Desktop.
Save jasontbradshaw/f4a2f4ca6f874a3e4745 to your computer and use it in GitHub Desktop.
isostick ISO Selector Script
#!/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