From e70b8beb7c33c395aa156530c8d555e4245df5d7 Mon Sep 17 00:00:00 2001 From: ranomier Date: Wed, 1 Jan 2025 15:15:11 +0100 Subject: [PATCH] no need to auto format if there is no change --- nswitch | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nswitch b/nswitch index bebad7e..d90d804 100755 --- a/nswitch +++ b/nswitch @@ -24,11 +24,15 @@ exit_with_new_shell() { cd "$PROJECT" || exit 1 nvim +# check if there are changes at all +[[ -z "$(git diff -U0 "$GIT_PATTERN")" ]] && echo ">>> no changes, exiting ..." && exit_with_new_shell + +# only then do auto formating printf ">>> auto formating ..." nix fmt . &> /dev/null printf " DONE!\n" -[[ -z "$(git diff -U0 "$GIT_PATTERN")" ]] && echo ">>> no changes, exiting ..." && exit_with_new_shell +# and then show the user a diff git diff -U0 "$GIT_PATTERN" # as a seperate command so we get nice colors and pager printf ">>> Do you want to rebuild NixOS? [y/N]\n"