Skip to content

Instantly share code, notes, and snippets.

@rrbutani
Created February 20, 2020 23:46
Show Gist options
  • Save rrbutani/5a1e20f5dfb342abbd25aba60d059951 to your computer and use it in GitHub Desktop.
Save rrbutani/5a1e20f5dfb342abbd25aba60d059951 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Go to the directory where you want to install all these things:
# - i.e.: `mkdir -p /dev/shm/__ && cd !$`
#
# Copy this script into that dir:
# - i.e.: `cp <path/to/script> !$`
#
# And then source this script:
# - i.e.: `source sourceme`
# dir="$(dirname "$(realpath "${0}")")"
dir="$(dirname "$(readlink -e "${0}")")"
PYENV=".pyenv"
RUSTUP=".rustup"
CARGO=".cargo"
export RUSTUP_HOME="${dir}/${RUSTUP}"
export CARGO_HOME="${dir}/${CARGO}"
pushd . > /dev/null
echo "Using \`${dir}\` ($(pwd)) to set things up!"
error() { echo "${1-error}"; exit "${2-4}"; }
cd "${dir}" || error "couldn't cd!" 9
# One equal here instead of two because zsh!!
if [ "$(uname -n)" = "luigi" ]; then
echo "On luigi, shadowing libdl.."
# libdl on luigi is broken somehow...
export LDFLAGS="-L${HOME}/libs/"
export LIBRARY_PATH=${LIBRARY_PATH}:${HOME}/libs/
fi
if [ ! -d "${PYENV}" ]; then
echo "pyenv not found, cloning..."
git clone https://github.com/pyenv/pyenv.git "${PYENV}"
git --git-dir="${PYENV}"/.git --work-tree="${PYENV}" checkout v1.2.14
export PYENV_ROOT="${dir}/${PYENV}"
export PATH="${PYENV_ROOT}/bin:${PATH}"
export HAVE_DYNAMIC_LOADING=true
pyenv install 3.8.0
else
export PYENV_ROOT="${dir}/${PYENV}"
export PATH="${PYENV_ROOT}/bin:${PATH}"
fi
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
if [ ! -d "${RUSTUP}" ]; then
echo "rustup not found, installing..."
curl --tlsv1.2 -sSfL "https://sh.rustup.rs" | sh
export PATH="${CARGO}/bin:${PATH}"
cargo install ripgrep loc fd hexyl irust
else
export PATH="${CARGO}/bin:${PATH}"
fi
popd > /dev/null || error "couldn't go back"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment