From cadc67571a60bc37ea76f5f9172e8df96b768cfa Mon Sep 17 00:00:00 2001 From: Jim Richter Date: Tue, 18 May 2021 11:16:36 +0200 Subject: [PATCH] add asdf-update script --- configs/zsh/functions.zsh | 3 ++- configs/zsh/functions/asdf-update.zsh | 36 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 configs/zsh/functions/asdf-update.zsh diff --git a/configs/zsh/functions.zsh b/configs/zsh/functions.zsh index c701202..29b2b71 100644 --- a/configs/zsh/functions.zsh +++ b/configs/zsh/functions.zsh @@ -5,4 +5,5 @@ source $(dirname "$0")/functions/wp.zsh; source $(dirname "$0")/functions/y.zsh; source $(dirname "$0")/functions/fp.zsh; source $(dirname "$0")/functions/mke.zsh; -source $(dirname "$0")/functions/rn.zsh; \ No newline at end of file +source $(dirname "$0")/functions/rn.zsh; +source $(dirname "$0")/functions/asdf-update.zsh; \ No newline at end of file diff --git a/configs/zsh/functions/asdf-update.zsh b/configs/zsh/functions/asdf-update.zsh new file mode 100644 index 0000000..f1ede7f --- /dev/null +++ b/configs/zsh/functions/asdf-update.zsh @@ -0,0 +1,36 @@ +function asdf-update(){ + + function log () { + printf "%s %s\n" "->" "$1" + } + + log "Updating all asdf-plugin remotes..." + + asdf plugin update --all + + log "Updating each plugin reference to the latest revision..." + + # TODO: Maybe refactor this shit, ew. + cat ~/.tool-versions \ + | awk '{print $1}' \ + | xargs -I {} bash -c 'echo {} $(asdf latest {})' > ~/.tool-versions.new; \ + cp ~/.tool-versions ~/.tool-versions.bk; \ + mv ~/.tool-versions.new ~/.tool-versions + + log "Old revision versions:" + cat ~/.tool-versions.bk + log "New revision versions:" + cat ~/.tool-versions + + while true; do + read yn"?Do you wish to install all new revisions?" + case $yn in + [Yy]* ) asdf install; break;; + [Nn]* ) exit;; + * ) log "Please answer Yes or No.";; + esac + done + + log "Done, bye! 👋" + +} \ No newline at end of file