Skip to content

Instantly share code, notes, and snippets.

@brucebentley
Last active November 28, 2023 22:02
Show Gist options
  • Save brucebentley/1c87a5b6658a26e23a4aaae77cdbc3aa to your computer and use it in GitHub Desktop.
Save brucebentley/1c87a5b6658a26e23a4aaae77cdbc3aa to your computer and use it in GitHub Desktop.
Example script to install ASDF along with some common plugins & their latest versions.
#!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Update Homebrew:
# - - - - - - - - - - - - - - - - - - - - - - - - -
brew update
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Install asdf dependencies:
# - - - - - - - - - - - - - - - - - - - - - - - - -
brew install coreutils curl gcc git gpg xz
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Install asdf using the Homebrew package manager:
# - - - - - - - - - - - - - - - - - - - - - - - - -
brew install asdf
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Add asdf.sh to your ~/.zshrc with:
# - - - - - - - - - - - - - - - - - - - - - - - - -
echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ~/.zshrc
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Install ASDF Plugins
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# See: https://asdf-vm.com/#/plugins-all?id=plugin-list for the full list of plugins.
#
asdf plugin add golang
asdf plugin add java
asdf plugin add mysql
asdf plugin add postgres
asdf plugin add python
asdf plugin add ruby
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Node.js
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# See https://github.com/asdf-vm/asdf-nodejs/#install for more info.
#
asdf plugin add nodejs
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Import The Node.js OpenPGP Keys:
# - - - - - - - - - - - - - - - - - - - - - - - - -
bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# PHP
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# Note:
# PHP requires some additional dependencies to be installed & configured.
# See https://github.com/asdf-community/asdf-php#prerequirements for more info.
#
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Install Additional Homebrew Dependencies
# - - - - - - - - - - - - - - - - - - - - - - - - -
#brew install autoconf automake bison freetype gettext icu4c krb5 libedit libiconv libjpeg libpng libxml2 libzip pkg-config re2c zlib
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Add `$PKG_CONFIG_PATH` Environment Variable:
# - - - - - - - - - - - - - - - - - - - - - - - - -
#export PKG_CONFIG_PATH="$(brew --prefix icu4c)/lib/pkgconfig:$(brew --prefix krb5)/lib/pkgconfig:$(brew --prefix libedit)/lib/pkgconfig:$(brew --prefix libxml2)/lib/pkgconfig:$(brew --prefix openssl)/lib/pkgconfig"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Add `bison` to `$PATH`:
# - - - - - - - - - - - - - - - - - - - - - - - - -
#export PATH="$(brew --prefix bison)/bin:$PATH"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Install The PHP Plugin:
# - - - - - - - - - - - - - - - - - - - - - - - - -
asdf plugin add php
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# List Installed Plugins:
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
asdf plugin list
# asdf plugin list
# golang
# java
# nodejs
# php
# python
# ruby
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create a `$HOME/.tool-versions` Configuration File
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# This file defines your global plugins & their installed versions.
#
# Note:
# Whenever .tool-versions file is present in a directory, the tool versions
# it declares will be used in that directory and any subdirectories.
#
{
echo -e "golang $(asdf latest golang)
java $(asdf latest java openjdk)
php $(asdf latest php)
python $(asdf latest python)
ruby $(asdf latest ruby)"
} >> ~/Desktop/asdf-test/.tool-versions
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Install Plugin Versions Defined In `$HOME/.tool-versions`:
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
asdf install
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Legacy Version Manager Support
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# By adding `legacy_version_file = yes` to the `$HOME/.asdfrc` configuration file,
# it enables asdf to read the version files used by other version managers.
# (e.g. `.ruby-version` in the case of Ruby’s `rbenv`.)
#
echo -e "legacy_version_file = yes" >> ~/Desktop/asdf-test/.asdfrc
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Test Each Plugins Installation & Version:
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
which go && go version
which java && java --version
which node && node --version
which php && php --version
which python && python -V
which ruby && ruby --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment