Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ Thumbs.db
!.ssh/config
.aws/*
!.aws/config
.asdf
.asdf/*
.composer/*
.dlv/*
!.dlv/config.yml
Expand Down
24 changes: 5 additions & 19 deletions MacOS/base
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function are_basics_installed() {
# `awscli` https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html
declare -a BREW_BASICS=(
'actionlint'
'asdf'
'awscli'
'bash'
'coreutils'
Expand All @@ -32,6 +31,7 @@ function are_basics_installed() {
'bitwarden-cli'
'mackup'
'mas'
'mise'
'oh-my-posh'
'parallel'
'pssh'
Expand All @@ -49,26 +49,12 @@ function are_basics_installed() {
install_if_not_installed 'brew' "${ASK}" "${BREW_BASICS[@]}"
}

function is_asdf_installed() {
function is_mise_installed() {
local ASK="${1:-'y'}"
if ! command -v asdf &> /dev/null || ! command -v brew &> /dev/null; then
declare -a ASDF_DEPS=('autoconf'
'automake'
'coreutils'
'gcc'
'libtool'
'libxslt'
'libyaml'
'openssl'
'make'
'readline'
'unixodbc'
'unzip')
if ! command -v mise &> /dev/null || ! command -v brew &> /dev/null; then
msg_info 'Will try to install brew if not installed'
are_basics_installed "${ASK}"
msg_info 'Will try to install asdf dependencies'
install_if_not_installed 'brew' "${ASK}" "${ASDF_DEPS[@]}"
msg_info 'Will try to install asdf using git'
source_asdf
msg_info 'Will try to activate mise'
source_mise
fi
}
18 changes: 0 additions & 18 deletions MacOS/bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,6 @@ if [ -f "$(brew --prefix)"/etc/bash_completion ]; then
source "$(brew --prefix)"/etc/bash_completion
fi

# `asdf` is now managed by homebrew
export ASDF_DATA_DIR="${HOME}/.asdf"
# shellcheck disable=SC1090
. <(asdf completion bash)
# Hook direnv into your shell.
# shellcheck disable=SC1091
. "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/bashrc"

# Go specific env vars
GOPATH="${HOME}/src/gopath"
GOROOT="$(asdf where golang)/go"
export GOPATH GOROOT

# Java specific env vars
JDK_HOME="$(asdf where java)"
JAVA_HOME="$(asdf where java)/jre"
export JDK_HOME JAVA_HOME

# Update PATH
export PATH="$(brew --prefix)/opt/curl/bin:${PATH}:${HOME}/src/gopath/bin:${HOME}/bin"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Keep key configurations and share them among your computers

- Installs:
- [1password-cli](https://support.1password.com/command-line/)
- [asdf](https://github.com/asdf-vm/asdf)
- [mise](https://github.com/jdx/mise)
- [awscli](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html)
- [oh-my-posh](https://ohmyposh.dev)
- [bfg](https://rtyley.github.io/bfg-repo-cleaner/)
Expand Down
29 changes: 6 additions & 23 deletions Ubuntu/base
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ function are_basics_installed() {
BREW_BASICS=(
'actionlint'
'asciidoc'
'asdf'
'awscli'
'fontconfig'
'gcc'
Expand All @@ -53,6 +52,7 @@ function are_basics_installed() {
'jless'
'jq'
'mackup'
'mise'
'oh-my-posh'
'parallel'
'pssh'
Expand All @@ -71,29 +71,12 @@ function are_basics_installed() {
install_if_not_installed 'brew' "${ASK}" "${BREW_BASICS[@]}"
}

function is_asdf_installed() {
function is_mise_installed() {
local ASK="${1:-'y'}"
if [[ ! -e "${HOME}/.asdf/asdf.sh" ]] || [[ ! -e "$(get_brew_location)" ]]; then
# Ubuntu 18.04 `apt install -y libncurses-dev libxslt-dev` gives the output below
# Note, selecting 'libncurses5-dev' instead of 'libncurses-dev'
# Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
declare -a ASDF_DEPS=('autoconf'
'automake'
'libbz2-dev'
'libffi-dev'
'libncurses5-dev'
'libreadline-dev'
'libsqlite3-dev'
'libssl-dev'
'libtool'
'libxslt1-dev'
'libyaml-dev'
'unixodbc-dev'
'unzip')
if ! command -v mise &> /dev/null || [[ ! -e "$(get_brew_location)" ]]; then
msg_info 'Will try to install brew if not installed'
are_basics_installed "${ASK}"
msg_info 'Will try to install asdf dependencies'
install_if_not_installed 'apt' "${ASK}" "${ASDF_DEPS[@]}"
msg_info 'Will try to install asdf using git'
source_asdf
msg_info 'Will try to activate mise'
source_mise
fi
}
18 changes: 0 additions & 18 deletions Ubuntu/bash_profile
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

# `asdf` is now managed by homebrew
export ASDF_DATA_DIR="${HOME}/.asdf"
# shellcheck disable=SC1090
. <(asdf completion bash)
# Hook direnv into your shell.
# shellcheck disable=SC1091
. "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/bashrc"

# Go specific env vars
GOPATH="${HOME}/src/gopath"
GOROOT="$(asdf where golang)/go"
export GOPATH GOROOT

# Java specific env vars
JDK_HOME="$(asdf where java)"
JAVA_HOME="$(asdf where java)/jre"
export JDK_HOME JAVA_HOME

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
Expand Down
6 changes: 0 additions & 6 deletions asdfrc

This file was deleted.

25 changes: 8 additions & 17 deletions bash_aliases
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,9 @@ function clean-multipass() {
multipass purge
}

function asdf-all () {
awk '{ print $1 }' ~/.tool-versions | grep -v '^#'
}

function asdf-all-versions () {
for i in $(asdf plugin list); do
echo "Plugin ${i} and versions are $(asdf list "${i}")"
function mise-all-versions () {
for i in $(mise plugin ls); do
echo "Plugin ${i} and versions are $(mise ls -i "${i}")"
done
}

Expand Down Expand Up @@ -282,7 +278,7 @@ function pkg_update() {
"system"
"mas"
"brew"
"asdf"
"mise"
"nodejs"
"gem"
"pip3"
Expand All @@ -299,7 +295,7 @@ function pkg_update() {
msg_info "Packages to update: ${pkgs[*]}"
for pkg in "${pkgs[@]}"; do
case "${pkg}" in
system|mas|brew|asdf|nodejs|gem|pip3|mackup)
system|mas|brew|mise|nodejs|gem|pip3|mackup)
pkg_update_"${pkg}"
;;
*)
Expand Down Expand Up @@ -359,14 +355,9 @@ function pkg_update_brew() {
brew update; brew upgrade; brew cleanup;
}

function pkg_update_asdf() {
msg_info 'cd ~/.asdf/plugins/python/pyenv/ && git pull && cd -'
cd ~/.asdf/plugins/python/pyenv/ || return 1
git pull
cd - || return 1

msg_info 'asdf plugin update --all'
asdf plugin update --all
function pkg_update_mise() {
msg_info 'mise plugins ls | xargs -L1 mise plugins update'
mise plugins ls | xargs -L1 mise plugins update
}

function pkg_update_nodejs() {
Expand Down
4 changes: 4 additions & 0 deletions bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ eval "$(oh-my-posh init bash --config "${HOME}"/.ohmyposh.json)"
if [ -f "${HOME}/.config/fabric/fabric-bootstrap.inc" ]; then
. "${HOME}/.config/fabric/fabric-bootstrap.inc"
fi

# activate mise
# https://mise.jdx.dev/
eval "$(mise activate bash)"
1 change: 0 additions & 1 deletion envrc

This file was deleted.

124 changes: 13 additions & 111 deletions lib/utils
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@ function get_latest_github_tag() {
echo -n "${latest_tag}"
}

function source_asdf() {
function source_mise() {
disableStrictMode
export ASDF_DATA_DIR="${HOME}/.asdf"
# shellcheck disable=SC1090
. <(asdf completion bash)
eval "$(mise activate bash)"
strictMode
}

Expand Down Expand Up @@ -179,9 +177,8 @@ function get_user_reply() {

# Install everything else
function install_everything_else() {
# Install asdf plugins and tools' versions
install_asdf_tool_versions
configure_direnv
# Install mise plugins and tools' versions
install_mise_tool_versions
hash -r

msg_info "Sourcing ${HOME}/.bashrc"
Expand Down Expand Up @@ -363,108 +360,13 @@ function get_git_tags() {
| LC_ALL=C sort -t '.' -k 1,1n -k 2,2n -k 3,3n -k 4,4d -k 5,5d
}

function install_asdf_tool_versions() {
# How to:
# only to be used after asdf has been installed and asdf's:
# `${HOME}/.asdf/shims:${HOME}/.asdf/bin`
# are in ${PATH}
local TOOLS_VERSIONS="${HOME}/.tool-versions" VERSION
declare -a PLUGINS=()
msg_info 'Installing asdf plugins'
mapfile -t PLUGINS < <(awk '{ print $1 }' "${TOOLS_VERSIONS}" | grep -v '#')
for PLUGIN in "${PLUGINS[@]}"; do
install_asdf_tool "${PLUGIN}"
VERSION="$(grep "${PLUGIN} " "${TOOLS_VERSIONS}" | awk '{ print $2 }')"
install_asdf_tool_version "${PLUGIN}" "${VERSION}"
done
}

function install_asdf_tool() {
local PLUGIN="${1}"
local PLUGIN_REPO="${2:- }"
local COMMAND="asdf plugin add ${PLUGIN} ${PLUGIN_REPO}"
if eval "${COMMAND}" &> /dev/null; then
msg_info "asdf plugin ${PLUGIN} was installed"
else
msg_warn "asdf plugin ${PLUGIN} was not installed"
fi
}

function install_asdf_tool_version() {
local PLUGIN="${1}"
local VERSION="${2}"
local CATCH_OUTPUT
CATCH_OUTPUT=$(mktemp install_asdf_tool_versions.XXXXXXX)
if asdf install "${PLUGIN}" "${VERSION}" &> "${CATCH_OUTPUT}"; then
msg_info "Installed ${PLUGIN} version ${VERSION} from ${TOOLS_VERSIONS}"
rm -f "${CATCH_OUTPUT}"
else
msg_error "I was not able to ${PLUGIN} version ${VERSION} from ${TOOLS_VERSIONS}, error is below:"
msg_error "$(cat "${CATCH_OUTPUT}")"
rm -f "${CATCH_OUTPUT}"
msg_error 'Will move on'
fi
}

function write_direnvrc() {
msg_info 'Creating file ~/.config/direnv/direnvrc'
cat <<'EOF' > "${HOME}"/.config/direnv/direnvrc
# Uncomment the following line to make direnv silent by default.
#export DIRENV_LOG_FORMAT=""
EOF
}

function write_use_asdf_sh() {
msg_info 'Creating file ~/.config/direnv/lib/use_asdf.sh'
mkdir -p "${HOME}"/.config/direnv/lib
# if you need to debug why a plugin is not installing correctly change the below to
# use_asdf() {
# set -x
# source_env "$(asdf cmd direnv envrc.bash "$@")" 2>&1 | tee -a /path/to/use_asdf.log
# set +x
# }
cat <<'EOF' > "${HOME}"/.config/direnv/lib/use_asdf.sh
### Do not edit. This was autogenerated by 'asdf cmd direnv setup.bash' ###
use_asdf() {
source_env "$(asdf cmd direnv envrc.bash "$@")"
}
EOF
}

function write_use_asdf_direnv_bashrc() {
msg_info 'Creating file ~/.config/asdf-direnv/bashrc'
cat <<EOF > "${HOME}"/.config/asdf-direnv/bashrc
### Do not edit. This was autogenerated by 'asdf cmd direnv setup.bash' ###
VER="\$(asdf current --no-header direnv | awk '{ print \$2 }')"
export ASDF_DIRENV_BIN="\${HOME}/.asdf/installs/direnv/\${VER}/bin/direnv"
eval "\$("\${ASDF_DIRENV_BIN}" hook bash)"
EOF
}

function configure_direnv() {
local CONFIG_FOLDER="${HOME}/.config"
local DIRENV_CONFIG_FOLDER="${CONFIG_FOLDER}/direnv"
msg_info 'Making ~/.asdf/plugins/direnv/lib/commands/command-*.bash executable'
msg_info 'Temp fix due to https://github.com/asdf-community/asdf-direnv/issues/194#issuecomment-2634107541'
chmod +x ~/.asdf/plugins/direnv/lib/commands/command-*.bash
if [[ ! -e "${DIRENV_CONFIG_FOLDER}" ]]; then
msg_info "${DIRENV_CONFIG_FOLDER} does not exist, I will create it"
mkdir -p "${DIRENV_CONFIG_FOLDER}"
fi
if [[ ! -e "${DIRENV_CONFIG_FOLDER}/direnvrc" ]]; then
msg_info "${DIRENV_CONFIG_FOLDER}/direnvrc does not exist, I'll create it now"
write_direnvrc
fi
if [[ ! -e "${DIRENV_CONFIG_FOLDER}/lib/use_asdf.sh" ]]; then
msg_info "${DIRENV_CONFIG_FOLDER}/lib/use_asdf.sh does not exist, I'll create it now"
write_use_asdf_sh
fi
if [[ ! -e "${CONFIG_FOLDER}/asdf-direnv" ]]; then
msg_info "${CONFIG_FOLDER}/asdf-direnv does not exist, I'll create it now"
mkdir -p "${CONFIG_FOLDER}/asdf-direnv"
fi
if [[ ! -e "${CONFIG_FOLDER}/asdf-direnv/bashrc" ]]; then
msg_info "${CONFIG_FOLDER}/asdf-direnv/bashrc does not exist, I'll create it now"
write_use_asdf_direnv_bashrc
fi
function install_mise_tool_versions() {
# cd to home folder
cd || exit 1
mise install
# come back to folder we were before we went to home folder
cd - || exit 1
# trust `mise/config.toml` so tools and their versions are available in this
# repo too
mise trust
}
1 change: 0 additions & 1 deletion mackup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ arara
aria2c
arm
asciinema
asdf
aspell
astyle
atlantis
Expand Down
Loading