From 4d64de1fa40130928c28c61b955475372e24dae2 Mon Sep 17 00:00:00 2001 From: bretello Date: Fri, 14 Feb 2020 16:37:44 +0100 Subject: [PATCH] improve self-update mechanism now updating amix's vimrc and oh-my-zsh custom plugins --- check_for_update.sh | 21 +++++++++++++++++++-- install.sh | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/check_for_update.sh b/check_for_update.sh index c5808ea..08384ba 100755 --- a/check_for_update.sh +++ b/check_for_update.sh @@ -1,6 +1,7 @@ #!/usr/bin/env zsh # -# brethil, brutally copied form https://github.com/robbyrussell/oh-my-zsh/blob/master/tools/check_for_upgrade.sh +# brethil, brutally copied from https://github.com/robbyrussell/oh-my-zsh/blob/master/tools/check_for_upgrade.sh +# This also tries to update amix's vimrc and oh-my-zsh # 14 July 2017 zmodload zsh/datetime @@ -14,7 +15,23 @@ function _update_dotfiles_update() { } function _upgrade_dotfiles() { - (cd $DOTFILES; git pull) + (cd $DOTFILES; git pull --rebase &>/dev/null && echo "Succesfully upgraded dotfiles" || echo "Could not upgrade dotfiles") + # amix's vimrc update + amix_vimrc=$HOME/.vim_runtime + if [[ -d $amix_vimrc ]]; then + # the update_plugins.py script makes the vim_runtime dir dirty, so we have to reset --hard + (cd $amix_vimrc && git reset --hard HEAD >/dev/null && git pull --rebase >/dev/null && echo "Upgraded amix's vimrc" || echo "Could not upgrade amix's vimrc" >&2) + (python $amix_vimrc/update_plugins.py >/dev/null || echo "upgraded amix's vimrc's plugins || "echo "Could not upgrade amix's vimrc's plugins" >&2) + else + echo "Could not upgrade amix's vimrc and plugins (missing .vim_runtime folder)" >&2 + fi + + # custom zsh plugins + custom_plugins=("alias-tips" "fast-syntax-highlighting" "zsh-autosuggestions") + for plugin in $custom_plugins; do + (cd $ZSH/custom/plugins/$plugin && git pull --rebase >/dev/null && echo "Upgraded oh-my-zsh plugin: $plugin" || echo "Could not upgrade oh-my-zsh plugin: $plugin" >&2) + done + # update the zsh file _update_dotfiles_update } diff --git a/install.sh b/install.sh index fa4b2a8..88312da 100755 --- a/install.sh +++ b/install.sh @@ -46,6 +46,7 @@ function install_zsh_plugins { # Install fast-syntax-highlighting (git: zdharma), zsh-autosuggestions (git:zsh-users), alias-tips ZSH_PLUGINS="$HOME/.oh-my-zsh/custom/plugins" mkdir -p "$ZSH_PLUGINS" + # NOTE: if adding plugins here, be sure to also add them to the _dotfiles_upgrade function in check_for_upgrade.sh git clone https://github.com/zdharma/fast-syntax-highlighting.git "${ZSH_PLUGINS}/fast-syntax-highlighting" || error=true git clone https://github.com/zsh-users/zsh-autosuggestions "${ZSH_PLUGINS}/zsh-autosuggestions" || error=true git clone https://github.com/djui/alias-tips.git "${ZSH_PLUGINS}/alias-tips" || error=true