Skip to content

Instantly share code, notes, and snippets.

@tmlbl
Last active March 20, 2016 06:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tmlbl/430f7d54cda16a43bff6 to your computer and use it in GitHub Desktop.
Save tmlbl/430f7d54cda16a43bff6 to your computer and use it in GitHub Desktop.
JVM - Julia Version Manager
#!/bin/bash
# I keep Julia binaries in /opt/julia with the same directory structure
# as ~/.julia to store different versions, and use this script to switch
# between them. I also like to maintain a link of the ~/.julia folder to
# ~/julia, for easier package development.
JBIN=""
PDIR=""
if [[ ! "$1" ]]; then
echo "Please specify a version, i.e."
echo "$ jvm 0.4"
exit 1
fi
# Look for the package directory
if [[ -d "$HOME/.julia/$1" ]]; then
PDIR="$HOME/.julia/$1"
elif [[ -d "$HOME/.julia/v$1" ]]; then
PDIR="$HOME/.julia/v$1"
else
echo "No Julia packages for version $1 found."
exit 1
fi
# Look for the executable
if [[ -d "/opt/julia/$1" ]]; then
JBIN="/opt/julia/$1/bin/julia"
elif [[ -d "/opt/julia/v$1" ]]; then
JBIN="/opt/julia/v$1/bin/julia"
else
echo "Didn't find the executable in /opt/julia/<version>"
exit 1
fi
echo "Linking executable for version $1..."
sudo rm /usr/bin/julia
sudo ln -s $JBIN /usr/bin/julia
echo "Linking packages shortcut for version $1..."
rm -r ~/julia; ln -s $PDIR ~/julia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment