Last active
November 14, 2017 17:10
-
-
Save plainspooky/1c4055c8d881ef5a4df13c06c7c9578d to your computer and use it in GitHub Desktop.
This Bash script creates a menu to an interactive selection to choose which MSX model to use on openMSX emulator.
This file contains 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 bash | |
set -eu | |
OPENMSX=$( which openmsx ) | |
if [[ ! -f ${OPENMSX} ]]; then | |
echo "openMSX not installed!" | |
exit 2 | |
else | |
echo "Select manufacturer:" | |
fi | |
OPENMSX_HOME="/usr/share/openmsx" | |
OPENMSX_MACHINES="${OPENMSX_HOME}/machines" | |
get_manufacturer_list(){ | |
{ | |
cd ${OPENMSX_MACHINES} | |
ls |\ | |
egrep "[A-Z].*\.xml" |\ | |
sed "s/Al_Alamiah/AlAlamiah/" |\ | |
sed "s/_[-A-Za-z0-9]\{2,3\}.*xml$//g" |\ | |
egrep -v "\.xml$" |\ | |
sed "s/AlAlamiah/Al_Alamiah/"; | |
} |\ | |
sort |\ | |
uniq | |
} | |
get_code_list(){ | |
{ | |
cd ${OPENMSX_MACHINES} | |
ls ${1}_*.xml |\ | |
sed "s/${1}_//" |\ | |
sed "s/.xml//" | |
} | sort | |
} | |
select manu in $( get_manufacturer_list ); do | |
if [[ ${manu} != "" ]]; then | |
PS3="${manu} [${REPLY}] #? " | |
echo -e "\nSelect model:" | |
select code in $( get_code_list ${manu} ); do | |
if [[ ${code} != "" ]]; then | |
echo -e "\nStarting openMSX..." | |
${OPENMSX} -machine ${manu}_${code} ${*} | |
break | |
fi | |
done | |
break | |
fi | |
done | |
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment