#!/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/" 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