From 7fc0ece8c257e4f3a8db0445e46d35ff3b0560f0 Mon Sep 17 00:00:00 2001 From: Soispha Date: Sun, 16 Apr 2023 08:05:25 +0200 Subject: Feat(hm/pkgs/scr/update): Add a cleaner cli interface --- .../packages/scripts/small_functions/update | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/home-manager/packages/scripts/small_functions/update b/home-manager/packages/scripts/small_functions/update index 23408327..cbe994c6 100755 --- a/home-manager/packages/scripts/small_functions/update +++ b/home-manager/packages/scripts/small_functions/update @@ -5,14 +5,14 @@ help() { cat << EOF - This is an Nixos flake update manager. +This is a Nixos flake update manager. - Usage: - "$name" [--branch ] [--help] +Usage: + $name [--branch ] [--help] - Options: - --branch | -b [branchname] select a branch to update from. - --help | -h output this help. +Options: + --branch | -b [branchname] select a branch to update from. + --help | -h output this help. EOF exit "$1"; } @@ -43,13 +43,20 @@ done cd /etc/nixos || die "No /etc/nixos"; -git pull --rebase > /dev/null; -if [ "$BRANCH" = "" ];then - git switch "$BRANCH" > /dev/null; - git pull --rebase; +msg "Starting system update..."; +git remote update origin --prune > /dev/null 2>&1; +if ! [ "$BRANCH" = "" ];then + git switch "$BRANCH" > /dev/null 2>&1 && msg2 "Switched to branch '$BRANCH'"; fi +msg2 "Updating git repository..."; +git pull --rebase; + git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' > $tmp & + +msg2 "Updating system..."; nixos-rebuild switch; -git switch "$(cat $tmp)" > /dev/null; + +git switch "$(cat $tmp)" > /dev/null 2>&1 && msg2 "Switched to branch '$(cat $tmp)'"; +msg "Finished Update!"; # vim: ft=sh -- cgit 1.4.1