From edc1934e83dc228eaae798c2347e920ec9b82c21 Mon Sep 17 00:00:00 2001 From: bretello Date: Sat, 6 Apr 2024 21:24:30 +0200 Subject: [PATCH] zsh: migrate from antibody to antidote See https://getantidote.github.io and https://github.com/mattmc3/antidote --- antibody_plugins.txt | 24 ------------- brethil_dotfile.sh | 68 ++++++++++++++++++++++++++----------- extras/check_for_update.zsh | 2 +- zsh_plugins.txt | 24 +++++++++++++ 4 files changed, 74 insertions(+), 44 deletions(-) delete mode 100644 antibody_plugins.txt create mode 100644 zsh_plugins.txt diff --git a/antibody_plugins.txt b/antibody_plugins.txt deleted file mode 100644 index bf36b82..0000000 --- a/antibody_plugins.txt +++ /dev/null @@ -1,24 +0,0 @@ -# vim:ft=zsh -djui/alias-tips -robbyrussell/oh-my-zsh -robbyrussell/oh-my-zsh path:plugins/ansible -robbyrussell/oh-my-zsh path:plugins/bgnotify -robbyrussell/oh-my-zsh path:plugins/colored-man-pages -robbyrussell/oh-my-zsh path:plugins/common-aliases -robbyrussell/oh-my-zsh path:plugins/docker -robbyrussell/oh-my-zsh path:plugins/docker-compose -robbyrussell/oh-my-zsh path:plugins/fzf -robbyrussell/oh-my-zsh path:plugins/git -robbyrussell/oh-my-zsh path:plugins/golang -robbyrussell/oh-my-zsh path:plugins/grc -robbyrussell/oh-my-zsh path:plugins/pip -robbyrussell/oh-my-zsh path:plugins/pyenv -robbyrussell/oh-my-zsh path:plugins/pylint -robbyrussell/oh-my-zsh path:plugins/sudo -robbyrussell/oh-my-zsh path:plugins/vagrant -robbyrussell/oh-my-zsh path:plugins/vi-mode -zsh-users/zsh-autosuggestions -zsh-users/zsh-completions -zsh-users/zsh-syntax-highlighting -joshskidmore/zsh-fzf-history-search -ryutok/rust-zsh-completions diff --git a/brethil_dotfile.sh b/brethil_dotfile.sh index c919ae9..1dd4b11 100755 --- a/brethil_dotfile.sh +++ b/brethil_dotfile.sh @@ -9,10 +9,52 @@ export VIRTUAL_ENV_DISABLE_PROMPT=true export PATH=$PATH:$HOME/bin -# Source all zsh plugins -source <(antibody init) -export ANTIBODY="$(antibody home)" -antibody bundle < "$DOTFILES/antibody_plugins.txt" +if [[ -d "$HOME/.cache/antibody" ]]; then + # antibody migration cleanup + rm -rf $HOME/.cache/antibody +fi + +if [[ ! -d $DOTFILES/antidote ]]; then + git clone https://github.com/mattmc3/antidote.git ${DOTFILES}/antidote +fi + +export ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh" +[[ -d $ZSH_CACHE_DIR ]] || mkdir -p $ZSH_CACHE_DIR + +# Lazy-load antidote from its functions directory. +fpath=($DOTFILES/antidote/functions/ $fpath) +autoload -Uz antidote + +autoload -Uz compinit && compinit +autoload -Uz bashcompinit && bashcompinit + + +# Lazy-load antidote and generate the static load file only when needed # TODO: look into deferred loading with zsh-defer +zsh_plugins="$DOTFILES/zsh_plugins" +if [[ ! ${zsh_plugins}.zsh -nt ${zsh_plugins}.txt ]]; then + ( + echo loading $zsh_plugins.txt + source $DOTFILES/antidote/antidote.zsh + + echo "ZSH=$(antidote path ohmyzsh/ohmyzsh)" >${zsh_plugins}.zsh + + antidote bundle <${zsh_plugins}.txt >>${zsh_plugins}.zsh + + if [[ $+commands[systemctl] ]]; then + antidote bundle robbyrussell/oh-my-zsh path:plugins/systemd >>${zsh_plugins}.zsh + fi + if [[ $+commands[pacman] ]]; then + antidote bundle robbyrussell/oh-my-zsh path:plugins/archlinux >>${zsh_plugins}.zsh + elif [[ $+commands[apt-get] ]]; then + antidote bundle robbyrussell/oh-my-zsh path:plugins/debian >>${zsh_plugins}.zsh + fi + +) +fi + +source ${zsh_plugins}.zsh +source "$DOTFILES/themes/brethil.zsh-theme" + # Setup completion style source $DOTFILES/completion_style.zsh @@ -25,20 +67,8 @@ else fi export FZF_CTRL_T_OPTS=" --preview-window=right,60% --preview \"bash -c 'if [[ -d \"{}\" ]]; then tree -C \"{}\"; else bat --style=plain --color=always \"{}\"; fi'\" --bind 'ctrl-/:change-preview-window(right,70%|down,40%,border-horizontal|hidden|right)'" -if [[ $+commands[systemctl] ]]; then - antibody bundle robbyrussell/oh-my-zsh path:plugins/systemd -fi -if [[ $+commands[pacman] ]]; then - antibody bundle robbyrussell/oh-my-zsh path:plugins/archlinux -elif [[ $+commands[apt-get] ]]; then - antibody bundle robbyrussell/oh-my-zsh path:plugins/debian -fi - ZSH_HIGHLIGHT_STYLES[comment]='fg=white,bg=gray,bold' -# Setup oh-my-zsh path -export ZSH="$(antibody path robbyrussell/oh-my-zsh)" - # Enable zsh autocorrection setopt CORRECT_ALL @@ -60,7 +90,7 @@ unsetopt LIST_BEEP ## Misc environment variables # https://www.xkcd.com/378/ -export EDITOR="vim" # if antibody_plugins.txt includes robbyrussell/oh-my-zsh path:plugins/vi-mode, this also sets `bindkey -v` +export EDITOR="vim" # if antibody_plugins.txt includes robbyrussell/oh-my-zsh path:plugins/vi-mode, this also sets `bindkey -v` # FIXME export VI_MODE_RESET_PROMPT_ON_MODE_CHANGE=true # refresh prompt on every mode change # Fix delete (delete! not backspace) key bindkey -a '^[[3~' delete-char @@ -147,8 +177,8 @@ test -f "${functions_file}" && source "${functions_file}" test -f "${aliases_file}" && source "${aliases_file}" test -f "${ssh_file}" && source "${ssh_file}" -autoload -U compinit && compinit -autoload -U bashcompinit && bashcompinit +# autoload -U compinit && compinit +# autoload -U bashcompinit && bashcompinit # Set DISABLE_DOTFILES_AUTOUPDATE=true to disable updates source "${DOTFILES}/extras/check_for_update.zsh" diff --git a/extras/check_for_update.zsh b/extras/check_for_update.zsh index b02d63b..585b771 100755 --- a/extras/check_for_update.zsh +++ b/extras/check_for_update.zsh @@ -30,7 +30,7 @@ function _update_dotfiles_update() { function update_dotfiles() { (cd $DOTFILES; git pull -q --rebase && echo "Succesfully upgraded dotfiles" || echo "Could not upgrade dotfiles.") - antibody update + (cd $DOTFILES/antidote && git pull -rebase || echo "Could not upgrade antidote") vim -c 'PlugUpdate|PlugClean|qa!' # update the zsh file _update_dotfiles_update diff --git a/zsh_plugins.txt b/zsh_plugins.txt new file mode 100644 index 0000000..5f1c3f5 --- /dev/null +++ b/zsh_plugins.txt @@ -0,0 +1,24 @@ +# vim:ft=zsh +djui/alias-tips +ohmyzsh/ohmyzsh path:lib +ohmyzsh/ohmyzsh path:plugins/ansible +ohmyzsh/ohmyzsh path:plugins/bgnotify +ohmyzsh/ohmyzsh path:plugins/colored-man-pages +ohmyzsh/ohmyzsh path:plugins/common-aliases +ohmyzsh/ohmyzsh path:plugins/docker +ohmyzsh/ohmyzsh path:plugins/docker-compose +ohmyzsh/ohmyzsh path:plugins/fzf +ohmyzsh/ohmyzsh path:plugins/git +ohmyzsh/ohmyzsh path:plugins/golang +ohmyzsh/ohmyzsh path:plugins/grc +ohmyzsh/ohmyzsh path:plugins/pip +ohmyzsh/ohmyzsh path:plugins/pyenv +ohmyzsh/ohmyzsh path:plugins/pylint +ohmyzsh/ohmyzsh path:plugins/sudo +ohmyzsh/ohmyzsh path:plugins/vagrant +ohmyzsh/ohmyzsh path:plugins/vi-mode +zsh-users/zsh-autosuggestions +zsh-users/zsh-completions +zsh-users/zsh-syntax-highlighting +joshskidmore/zsh-fzf-history-search +ryutok/rust-zsh-completions