-
-
Save staticfloat/2686daca03fd36843e90127059ca8d7c to your computer and use it in GitHub Desktop.
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 | |
# Helper to jump to julia package source | |
function jlj() | |
{ | |
if [[ $# != 1 ]]; then | |
echo "Usage: jlj <package name>" >&2 | |
return | |
fi | |
PKG="$1" | |
DEPOTS1=$(echo ${JULIA_DEPOT_PATH:-${HOME}/.julia} | cut -d':' -f1) | |
# First, check to see if we've got a `dev`'ed version around | |
if [[ -d ${DEPOTS1}/dev/${PKG} ]]; then | |
cd ${DEPOTS1}/dev/${PKG} | |
# Spit out `git status` just for fun | |
echo "Found ${PKG} dev'ed out to ${DEPOTS1}/dev/${PKG}..." | |
git status | |
return | |
fi | |
# If not, we're going to look in `packages`; make sure it exists at all: | |
if [[ ! -d ${DEPOTS1}/packages/${PKG} ]]; then | |
echo "${PKG} is not installed at all!" >&2 | |
return | |
fi | |
# If we don't have a `dev`'ed version around, then see if there's only one version installed: | |
VERSIONS=(${DEPOTS1}/packages/${PKG}/*) | |
if [[ ${#VERSIONS[@]} == 1 ]]; then | |
cd ${VERSIONS[0]} | |
echo "Found ${PKG} installed in ${VERSIONS[0]}..." | |
return | |
fi | |
# Otherwise, ask Julia where it comes from | |
JULIA=${JULIA:-julia} | |
PKG_DIR=$(${JULIA} -e "using ${PKG}; println(dirname(dirname(Base.pathof(${PKG}))))" 2>/dev/null) | |
if [[ ! -d ${PKG_DIR} ]]; then | |
echo "Unable to find package ${PKG}, probably not installed in this environment!" >&2 | |
return | |
fi | |
echo "Found ${PKG} (1 of ${#VERSIONS[@]}) installed at ${PKG_DIR}..." | |
cd ${PKG_DIR} | |
return | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment