Last active
December 15, 2015 13:38
-
-
Save jiggak/5268365 to your computer and use it in GitHub Desktop.
Bash script for selecting minecraft instance to launch
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
#!/bin/bash | |
# directory containing minecraft instances | |
# create new subdirectory to add an instance | |
mchome=~/Games/minecraft | |
java_opts=-Xmx2048M -Xms1024M | |
white='\e[1;37m' | |
cyan='\e[0;36m' | |
blue='\e[0;34m' | |
green='\e[0;32m' | |
yellow='\e[0;33m' | |
reset='\e[0m' | |
instances=$(cd ${mchome}; ls -d */ | sed 's/\///') | |
if [ "$1" = "-v" ]; then | |
verbose=1 | |
fi | |
linked=$(readlink ~/.minecraft) | |
count=1 | |
for name in ${instances}; do | |
echo -e "${yellow}[${count}]: ${blue}${name}${reset}" | |
if [[ ${linked} == */${name} ]]; then | |
current=${name} | |
fi | |
count=$((${count}+1)) | |
done | |
echo -en "${white}Select instance to launch [${green}${current}${white}]:${reset} " | |
read input | |
if [ "${input}" != "" ]; then | |
instances=(${instances}) | |
tolink=${instances[$((${input}-1))]} | |
rm ~/.minecraft | |
ln -s ${mchome}/${tolink} ~/.minecraft | |
fi | |
if [ "${verbose}" = "1" ]; then | |
java -jar ${java_opts} ${mchome}/minecraft.jar | |
else | |
java -jar ${java_opts} ${mchome}/minecraft.jar >/dev/null 2>&1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment