Skip to content

Instantly share code, notes, and snippets.

@jiggak
Last active December 15, 2015 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiggak/5268365 to your computer and use it in GitHub Desktop.
Save jiggak/5268365 to your computer and use it in GitHub Desktop.
Bash script for selecting minecraft instance to launch
#!/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