From 746646ae554a5b90d778269abc6b66c10ac04bc3 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Fri, 22 Nov 2024 17:53:46 +0200 Subject: [PATCH] feat(shell): switched to antidote, asdf changes --- .gitignore | 1 + .gitmodules | 4 ++ .ignore | 5 ++- .nvmrc | 1 + .python-version | 1 + .tool-versions | 2 - add-submodules.sh | 7 ++++ base/envrc | 1 + base/nvmrc | 1 + base/tool-versions | 5 +-- base/{zshenv => zshrc} | 48 +++++++++++++++-------- config/asdf/plugin-versions | 4 +- config/asdf/python-packages | 1 - config/exports | 67 ++++++++++++++++++--------------- config/git/gitignore | 1 + config/zsh/antidote_plugins.txt | 31 +++++++++++++++ scripts/install-asdf.sh | 3 -- scripts/install-npm-packages.sh | 17 ++++----- scripts/install-pip-packages.sh | 3 -- tools/antidote | 1 + 20 files changed, 132 insertions(+), 72 deletions(-) create mode 100644 .nvmrc create mode 100644 .python-version delete mode 100644 .tool-versions create mode 100644 base/nvmrc rename base/{zshenv => zshrc} (75%) create mode 100644 config/zsh/antidote_plugins.txt create mode 160000 tools/antidote diff --git a/.gitignore b/.gitignore index 48b858e..a3f5b8f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,5 @@ config/gnupg/s config/gnupg/private-keys-v1.d config/nvim/spell/* !config/nvim/spell/.gitkeep +antidote_plugins.zsh diff --git a/.gitmodules b/.gitmodules index 0371589..fc91889 100644 --- a/.gitmodules +++ b/.gitmodules @@ -60,3 +60,7 @@ [submodule "asdf"] path = local/bin/asdf url = https://github.com/asdf-vm/asdf.git +[submodule "antidote"] + path = tools/antidote + url = https://github.com/mattmc3/antidote.git + shallow = true diff --git a/.ignore b/.ignore index 77896d0..ce8c918 100644 --- a/.ignore +++ b/.ignore @@ -1,6 +1,7 @@ .git/** config/cheat/cheatsheets/community/** -tools/dotbot/** +node_modules +tools/antidote/** tools/dotbot-brew/** tools/dotbot-include/** -node_modules +tools/dotbot/** diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..7af24b7 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22.11.0 diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..4eba2a6 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13.0 diff --git a/.tool-versions b/.tool-versions deleted file mode 100644 index c25266d..0000000 --- a/.tool-versions +++ /dev/null @@ -1,2 +0,0 @@ -python 3.13.0 -nodejs 22.11.0 diff --git a/add-submodules.sh b/add-submodules.sh index 2e19b34..4ef811c 100755 --- a/add-submodules.sh +++ b/add-submodules.sh @@ -17,6 +17,10 @@ git submodule add --name cheat-tldr \ -f https://github.com/ivuorinen/cheatsheet-tldr.git config/cheat/cheatsheets/tldr git submodule add --name asdf \ -f https://github.com/asdf-vm/asdf.git local/bin/asdf +git submodule add --name antidote \ + --depth 1 \ + -f https://github.com/mattmc3/antidote.git tools/antidote \ + # tmux plugin manager and plugins git submodule add --name tmux/tmux-continuum \ @@ -43,6 +47,9 @@ for MODULE in $(git config --file .gitmodules --get-regexp path | awk '{ print $ git config "submodule.${MODULE}.ignore" all done +# Mark certain repositories shallow +git config -f .gitmodules submodule.antidote.shallow true + # remove old submodules [ -d "config/tmux/plugins/tpm" ] && rm -rf config/tmux/plugins/tpm [ -d "config/tmux/plugins/tmux" ] && rm -rf config/tmux/plugins/tmux diff --git a/base/envrc b/base/envrc index a63eb96..8705332 100644 --- a/base/envrc +++ b/base/envrc @@ -1 +1,2 @@ +use node use asdf diff --git a/base/nvmrc b/base/nvmrc new file mode 100644 index 0000000..b009dfb --- /dev/null +++ b/base/nvmrc @@ -0,0 +1 @@ +lts/* diff --git a/base/tool-versions b/base/tool-versions index 635f067..aee7c70 100644 --- a/base/tool-versions +++ b/base/tool-versions @@ -1,7 +1,5 @@ asdf-plugin-manager 1.4.0 -nodejs 23.1.0 golang 1.23.3 -python 3.12.7 ruby 3.3.4 rust 1.82.0 direnv 2.35.0 @@ -14,7 +12,6 @@ editorconfig-checker 2.8.0 github-cli 2.61.0 hadolint 2.12.0 kubectl 1.31.2 -pipx 1.7.1 pre-commit 4.0.1 ripgrep 14.1.1 shellcheck 0.10.0 @@ -26,3 +23,5 @@ yq 4.44.3 bats 1.11.0 gitleaks 8.18.4 delta 0.18.1 +eza 0.20.8 +sops 3.9.1 diff --git a/base/zshenv b/base/zshrc similarity index 75% rename from base/zshenv rename to base/zshrc index abd472a..d72cdff 100644 --- a/base/zshenv +++ b/base/zshrc @@ -13,17 +13,34 @@ export SHARED_SCRIPTS_SOURCED=0 source "$DOTFILES/config/shared.sh" source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc" -export ZDOTDIR="$DOTFILES/zsh" ZSH_COMPDUMP="$XDG_CACHE_HOME/zsh/zcompdump-${SHORT_HOST}-${ZSH_VERSION}" - -# If not running interactively, don't do anything -case $- in - *i*) ;; - *) return;; -esac - eval "$(oh-my-posh init zsh --config "$DOTFILES/config/omp/own.toml")" +load_antidote() +{ + [[ ! -d "$ANTIDOTE_DIR" ]] && { + git submodule add \ + --name antidote \ + --depth=1 \ + -f https://github.com/mattmc3/antidote.git "${ANTIDOTE_DIR}" + git config -f .gitmodules submodule.antidote.shallow true + } + zstyle ':antidote:bundle' use-friendly-names 'yes' + + zsh_plugins=${ANTIDOTE_PLUGINS} + [[ -f ${zsh_plugins}.txt ]] || touch ${zsh_plugins}.txt + # Lazy-load antidote from its functions directory. + FPATH="$ANTIDOTE_DIR/functions:$FPATH" + autoload -Uz antidote + # Generate a new static file whenever .zsh_plugins.txt is updated. + if [[ ! ${zsh_plugins}.zsh -nt ${zsh_plugins}.txt ]]; then + antidote bundle <${zsh_plugins}.txt >|${zsh_plugins}.zsh + fi + + # Source your static plugins file. + source ${zsh_plugins}.zsh +} + # Function to load antigen if available load_antigen() { @@ -55,10 +72,15 @@ load_antigen() zstyle :omz:plugins:ssh-agent lazy yes zstyle :omz:plugins:ssh-agent quiet yes + # nvm + zstyle ':omz:plugins:nvm' autoload yes + # z, the zsh version export ZSHZ_DATA="$XDG_STATE_HOME/z" antigen bundle z + antigen bundle nvm + # these should be always available antigen bundle jreese/zsh-titles antigen bundle brew @@ -99,15 +121,11 @@ setup_tmux_window_name_plugin() fi } -load_antigen +# load_antigen +load_antidote source_fzf_config setup_tmux_window_name_plugin -if x-have antidot; then - eval "$(antidot init)" -fi - -# Lando -export PATH="$HOME/.lando/bin${PATH+:$PATH}"; #landopath +x-have antidot && eval "$(antidot init)" autoload -Uz compinit bashcompinit compinit -d $ZSH_COMPDUMP diff --git a/config/asdf/plugin-versions b/config/asdf/plugin-versions index 6960a98..e8338f2 100644 --- a/config/asdf/plugin-versions +++ b/config/asdf/plugin-versions @@ -7,16 +7,14 @@ delta https://github.com/andweeb/asdf-delta.git direnv https://github.com/asdf-community/asdf-direnv.git 6ff3dbe dotenv-linter https://github.com/wesleimp/asdf-dotenv-linter.git 1369f53 editorconfig-checker https://github.com/gabitchov/asdf-editorconfig-checker.git 585c1d5 +eza https://github.com/lwiechec/asdf-eza.git 11f578d fd https://gitlab.com/wt0f/asdf-fd.git 17d56e0 github-cli https://github.com/bartlomiejdanek/asdf-github-cli.git e0605b7 gitleaks https://github.com/jmcvetta/asdf-gitleaks.git 0cc0d7e golang https://github.com/asdf-community/asdf-golang.git e2527a3 hadolint https://github.com/devlincashman/asdf-hadolint.git 335e230 kubectl https://github.com/asdf-community/asdf-kubectl.git 2fb3b57 -nodejs https://github.com/asdf-vm/asdf-nodejs.git c36e6f0 -pipx https://github.com/yozachar/asdf-pipx.git 31db618 pre-commit https://github.com/jonathanmorley/asdf-pre-commit.git 26bfc42 -python https://github.com/asdf-community/asdf-python a3a0185 ripgrep https://gitlab.com/wt0f/asdf-ripgrep.git e836665 ruby https://github.com/asdf-vm/asdf-ruby.git 194fe45 rust https://github.com/code-lever/asdf-rust.git 95acf4f diff --git a/config/asdf/python-packages b/config/asdf/python-packages index 6267439..377042c 100644 --- a/config/asdf/python-packages +++ b/config/asdf/python-packages @@ -1,5 +1,4 @@ ansible pipenv -semgrep neovim libtmux diff --git a/config/exports b/config/exports index b5efd53..c6fea0d 100755 --- a/config/exports +++ b/config/exports @@ -22,14 +22,6 @@ export PATH="$XDG_BIN_HOME:$DOTFILES/local/bin:$XDG_DATA_HOME/bob/nvim-bin:$XDG_ # Add zsh completions to FPATH, compinit will be called later FPATH="$ZSH_COMPLETIONS:$FPATH" -# Load asdf -export ASDF_DIR="$XDG_BIN_HOME/asdf" -if [[ -d $ASDF_DIR ]]; then - [[ -d $ASDF_DIR/completions ]] && FPATH="$ASDF_DIR/completions:$FPATH" - [[ -d $ASDF_DIR/plugins ]] && FPATH="$ASDF_DIR/plugins:$FPATH" - source "$ASDF_DIR/asdf.sh" -fi - if ! command -v msg &> /dev/null; then # Function to print messages if VERBOSE is enabled # $1 - message (string) @@ -303,6 +295,41 @@ hash shopt 2> /dev/null && shopt -s checkwinsize export SHORT_HOST=$(hostname -s) +# asdf +# https://github.com/asdf-vm/asdf +msg "Setting up asdf configuration" +export ASDF_DIR="${XDG_BIN_HOME}/asdf" +if [[ -d $ASDF_DIR ]]; then + [[ -d $ASDF_DIR/completions ]] && FPATH="$ASDF_DIR/completions:$FPATH" + [[ -d $ASDF_DIR/plugins ]] && FPATH="$ASDF_DIR/plugins:$FPATH" + + export ASDF_CONFIG_FILE="${XDG_CONFIG_HOME}/asdf/asdfrc" + export ASDF_DATA_DIR="${ASDF_DIR}" + export ASDF_PLUGIN_MANAGER_PLUGIN_VERSIONS_FILENAME="${XDG_CONFIG_HOME}/asdf/plugin-versions" + export ASDF_LOG_FILE="${XDG_CACHE_HOME}/asdf/asdf.log" + export ASDF_FORCE_PREPEND=yes + ## Default package files + export ASDF_CRATE_DEFAULT_PACKAGES_FILE="${XDG_CONFIG_HOME}/asdf/cargo-packages" + export ASDF_GEM_DEFAULT_PACKAGES_FILE="${XDG_CONFIG_HOME}/asdf/gem-packages" + export ASDF_GOLANG_DEFAULT_PACKAGES_FILE="${XDG_CONFIG_HOME}/asdf/golang-packages" + export ASDF_NPM_DEFAULT_PACKAGES_FILE="${XDG_CONFIG_HOME}/asdf/npm-packages" + export ASDF_PYTHON_DEFAULT_PACKAGES_FILE="${XDG_CONFIG_HOME}/asdf/python-packages" + ## Plugin configuration + export ASDF_DIRENV_IGNORE_MISSING_PLUGINS=1 + export ASDF_GOLANG_MOD_VERSION_ENABLED=true + export ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY="latest_available" + ## Add asdf to path + export PATH="${ASDF_DIR}/bin:${PATH}" + + source "$ASDF_DIR/asdf.sh" +fi + +# Antidote configuration +# https://getantidote.github.io/ +msg "Setting up Antidote configuration" +export ANTIDOTE_DIR="$DOTFILES/tools/antidote" +export ANTIDOTE_PLUGINS="$XDG_CONFIG_HOME/zsh/antidote_plugins" + # Antigen configuration # https://github.com/zsh-users/antigen/wiki/Configuration msg "Setting up Antigen configuration" @@ -320,28 +347,6 @@ export ANSIBLE_GALAXY_CACHE_DIR="$XDG_CACHE_HOME/ansible/galaxy_cache" x-dc "$ANSIBLE_HOME" x-dc "$ANSIBLE_GALAXY_CACHE_DIR" -# asdf -# https://github.com/asdf-vm/asdf -msg "Setting up asdf configuration" -export ASDF_DIR="${XDG_BIN_HOME}/asdf" -export ASDF_CONFIG_FILE="${XDG_CONFIG_HOME}/asdf/asdfrc" -export ASDF_DATA_DIR="${ASDF_DIR}" -export ASDF_PLUGIN_MANAGER_PLUGIN_VERSIONS_FILENAME="${XDG_CONFIG_HOME}/asdf/plugin-versions" -export ASDF_LOG_FILE="${XDG_CACHE_HOME}/asdf/asdf.log" -export ASDF_FORCE_PREPEND=yes -## Default package files -export ASDF_CRATE_DEFAULT_PACKAGES_FILE="${XDG_CONFIG_HOME}/asdf/cargo-packages" -export ASDF_GEM_DEFAULT_PACKAGES_FILE="${XDG_CONFIG_HOME}/asdf/gem-packages" -export ASDF_GOLANG_DEFAULT_PACKAGES_FILE="${XDG_CONFIG_HOME}/asdf/golang-packages" -export ASDF_NPM_DEFAULT_PACKAGES_FILE="${XDG_CONFIG_HOME}/asdf/npm-packages" -export ASDF_PYTHON_DEFAULT_PACKAGES_FILE="${XDG_CONFIG_HOME}/asdf/python-packages" -## Plugin configuration -export ASDF_DIRENV_IGNORE_MISSING_PLUGINS=1 -export ASDF_GOLANG_MOD_VERSION_ENABLED=true -export ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY="latest_available" -## Add asdf to path -export PATH="${ASDF_DIR}/bin:${PATH}" - # aws # https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html # https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html @@ -436,6 +441,8 @@ export PYENV_ROOT="$XDG_STATE_HOME/pyenv" ## for MichaelAquilina/zsh-autoswitch-virtualenv export AUTOSWITCH_VIRTUAL_ENV_DIR="$WORKON_HOME" export PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH" +[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" +x-have pyenv && eval "$(pyenv init -)" # Rust / cargo msg "Setting up Rust/Cargo configuration" diff --git a/config/git/gitignore b/config/git/gitignore index e83712d..0ec3dcb 100644 --- a/config/git/gitignore +++ b/config/git/gitignore @@ -20,3 +20,4 @@ auth.json dfm.sh .scannerwork .phpactor.json +.zsh_history diff --git a/config/zsh/antidote_plugins.txt b/config/zsh/antidote_plugins.txt new file mode 100644 index 0000000..8b7ec46 --- /dev/null +++ b/config/zsh/antidote_plugins.txt @@ -0,0 +1,31 @@ +# This file is for Antidote plugins +# https://getantidote.github.io/usage +# vim: ft=ini + +# set up Zsh completions with plugins +mattmc3/ez-compinit +zsh-users/zsh-completions kind:fpath path:src + +# frameworks like oh-my-zsh are supported +getantidote/use-omz # handle OMZ dependencies +ohmyzsh/ohmyzsh path:lib # load OMZ's library +ohmyzsh/ohmyzsh path:plugins/colored-man-pages # load OMZ plugins + +ohmyzsh/ohmyzsh path:plugins/colored-man-pages +ohmyzsh/ohmyzsh path:plugins/extract +ohmyzsh/ohmyzsh path:plugins/z +ohmyzsh/ohmyzsh path:plugins/eza + +# Add some programmer plugins +ohmyzsh/ohmyzsh path:plugins/git +ohmyzsh/ohmyzsh path:plugins/golang +ohmyzsh/ohmyzsh path:plugins/python +ohmyzsh/ohmyzsh path:plugins/nvm + +# Add core plugins that make Zsh a bit more like Fish +zsh-users/zsh-completions path:src kind:fpath +zdharma-continuum/fast-syntax-highlighting + +# Add some plugins that are not in OMZ +jreese/zsh-titles +yuki-ycino/tms diff --git a/scripts/install-asdf.sh b/scripts/install-asdf.sh index c187d6e..bd9910a 100755 --- a/scripts/install-asdf.sh +++ b/scripts/install-asdf.sh @@ -33,10 +33,7 @@ ASDF_INSTALLABLES=( "golang:github.com/asdf-community/asdf-golang.git" "hadolint:github.com/devlincashman/asdf-hadolint.git" "kubectl:github.com/asdf-community/asdf-kubectl.git" - "nodejs:github.com/asdf-vm/asdf-nodejs.git" - "pipx:github.com/yozachar/asdf-pipx.git" "pre-commit:github.com/jonathanmorley/asdf-pre-commit.git" - "python:github.com/asdf-community/asdf-python.git" "ripgrep:gitlab.com/wt0f/asdf-ripgrep.git" "rust:github.com/code-lever/asdf-rust.git" "shellcheck:github.com/luizm/asdf-shellcheck.git" diff --git a/scripts/install-npm-packages.sh b/scripts/install-npm-packages.sh index 05f6528..f21884a 100755 --- a/scripts/install-npm-packages.sh +++ b/scripts/install-npm-packages.sh @@ -3,18 +3,15 @@ # # shellcheck source=shared.sh -echo "This file ($0) has been deprecated in favor of asdf. Please use asdf instead." -exit 0 - eval "$DOTFILES/config/shared.sh" # Enable verbosity with VERBOSE=1 VERBOSE="${VERBOSE:-0}" -msg "Starting to install npm packages" +msgr msg "Starting to install npm packages" if ! command -v npm &> /dev/null; then - msg_err "npm could not be found." + msgr err "npm could not be found." exit 0 fi @@ -38,9 +35,9 @@ install_packages() if [[ ${pkg:0:1} == "#" ]]; then continue; fi if npm ls -g -p "$pkg" &> /dev/null; then - msg_run_done "$pkg" "already installed" + msgr run_done "$pkg" "already installed" else - msg_run "Installing npm package:" "$pkg" + msgr run "Installing npm package:" "$pkg" npm install -g --no-fund --no-progress --no-timing "$pkg" fi echo "" @@ -50,7 +47,7 @@ install_packages() # Function to upgrade all global npm packages upgrade_global_packages() { - msg_run "Upgrading all global packages" + msgr run "Upgrading all global packages" npm -g --no-progress --no-timing --no-fund outdated npm -g --no-timing --no-fund upgrade } @@ -58,7 +55,7 @@ upgrade_global_packages() # Function to clean npm cache clean_npm_cache() { - msg_run "Cleaning up npm cache" + msgr run "Cleaning up npm cache" npm cache verify npm cache clean --force npm cache verify @@ -69,7 +66,7 @@ main() install_packages upgrade_global_packages clean_npm_cache - msg_yay "npm package installations complete" + msgr yay "npm package installations complete" } main "$@" diff --git a/scripts/install-pip-packages.sh b/scripts/install-pip-packages.sh index a0e5bc9..5c9081f 100755 --- a/scripts/install-pip-packages.sh +++ b/scripts/install-pip-packages.sh @@ -3,9 +3,6 @@ # # shellcheck source=shared.sh -echo "This file ($0) has been deprecated in favor of asdf. Please use asdf instead." -exit 0 - source "${DOTFILES}/config/shared.sh" # Enable verbosity with VERBOSE=1 diff --git a/tools/antidote b/tools/antidote new file mode 160000 index 0000000..64b7864 --- /dev/null +++ b/tools/antidote @@ -0,0 +1 @@ +Subproject commit 64b786480f632746704e8dcf20b0dab7ab4bb94d