From 7d09b9794e75b5532f4d9ab5d2d07402b8773cc7 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Mon, 19 Nov 2018 09:59:36 +0100 Subject: [PATCH] Show durations of updates --- zsh/update.zsh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/zsh/update.zsh b/zsh/update.zsh index d9bc824..2da7f3b 100644 --- a/zsh/update.zsh +++ b/zsh/update.zsh @@ -9,6 +9,7 @@ pull-dotfiles() { update() { + start=`date +%s` echo "\033[32;1m=== Starting the update, please enter your password ===\033[0m" # Ask for sudo right now @@ -20,6 +21,7 @@ update() { fi echo "\033[32;1m=== Updating system ===\033[0m" + start_system_update=`date +%s` # Debian based systems command -v apt > /dev/null 2>&1 @@ -53,6 +55,12 @@ update() { # Update rust if installed command -v rustup > /dev/null 2>&1 + + seconds=$((`date +%s` - $start_system_update )) + formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'` + echo "\033[32;1m=== System updated in $formatted ===\033[0m" + + start_rust_update=`date +%s` if [ $? -eq 0 ]; then echo "\033[32;1m=== Updating rustup ===\033[0m" rustup self update @@ -89,8 +97,19 @@ update() { cargo install-update -ag fi + seconds=$((`date +%s` - $start_rust_update )) + formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'` + echo "\033[32;1m=== Rust updated in $formatted ===\033[0m" + # Update the dotfiles + start_dotfiles_update=`date +%s` pull-dotfiles - echo "\033[32;1m=== Update finished ===\033[0m" + seconds=$((`date +%s` - $start_dotfiles_update )) + formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'` + echo "\033[32;1m=== Dotfiles updated in $formatted ===\033[0m" + + seconds=$((`date +%s` - $start_system_update )) + formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'` + echo "\033[32;1m=== Update finished in $formatted ===\033[0m" }