bin/homedir-setup

Wed, 31 Aug 2016 16:24:17 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Wed, 31 Aug 2016 16:24:17 -0400
changeset 381
b09db2db7f84
parent 328
b3b18ced6949
child 382
09a6309e4856
permissions
-rwxr-xr-x

use ruby and nodejs plugins for asdf

#!/bin/sh
set -eu

if [ ! -f .zshrc ]; then
  echo "Refusing to run without a .zshrc nearby" >&2
  exit 1
fi

if ! git --version >/dev/null; then
  echo "Please install git!" >&2
  exit 1
fi

pull () {
  echo "$1:"
  git -C $1 pull --no-tags
}

if ! [ -d .zgen ]; then
  git clone https://github.com/tarjoilija/zgen.git .zgen
else
  pull .zgen
fi

if ! [ -d .plenv ]; then
  git clone https://github.com/tokuhirom/plenv.git .plenv
  git clone https://github.com/tokuhirom/Perl-Build.git .plenv/plugins/perl-build/
else
  pull .plenv
  pull .plenv/plugins/perl-build
fi

if ! [ -d .asdf ]; then
  git clone https://github.com/asdf-vm/asdf .asdf
else
  pull .asdf
fi

for LANG in ruby nodejs erlang elixir; do
  if ! [ -d .asdf/plugins/$LANG ]; then
    git clone https://github.com/asdf-vm/asdf-$LANG .asdf/plugins/$LANG
  else
    pull .asdf/plugins/$LANG
  fi
done

set +eu
. .asdf/asdf.sh
set -eu

# Transition older stuff to asdf
if [ -d .rbenv ]; then
  echo 'Removing rbenv and moving ruby installs'

  mkdir -p .asdf/installs
  mv .rbenv/versions .asdf/installs/ruby
  pushd $!
  for ver in *; do
    asdf reshim ruby $ver
  done
  popd

  if [ -f .rbenv/version ]; then
    echo "ruby $(cat .rbenv/version)" >> .tool-versions
  fi

  rm -rf .rbenv
fi

if [ -d .ndenv ]; then
  echo 'Removing ndenv and moving node installs'

  mkdir -p .asdf/installs
  mv .ndenv/versions .asdf/installs/nodejs
  pushd $!
  for ver in *; do
    asdf reshim nodejs $ver
  done
  popd

  if [ -f .ndenv/version ]; then
    echo "nodejs $(cat .ndenv/version)" >> .tool-versions
  fi

  rm -rf .ndenv
fi

mercurial