From 5ee1c7eddb1fffd94003cf49750180c1e9f96e8d Mon Sep 17 00:00:00 2001 From: ranomier Date: Wed, 8 Jan 2025 16:14:42 +0100 Subject: [PATCH 1/3] more expressive --- nswitch | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nswitch b/nswitch index e90d6a5..bf6e36b 100755 --- a/nswitch +++ b/nswitch @@ -41,12 +41,15 @@ if ! [[ "${YESNO,,}" == "y" ]]; then exit_with_new_shell fi +printf ">>> Add everything to git staging so nix can find it\n" git add "$GIT_PATTERN" printf ">>> Rebuilding NixOS\n" sudo nixos-rebuild switch | tee nixos-switch.log || ( grep --color error nixos-switch.log && false) gen=$(nixos-rebuild list-generations | grep current) + +printf ">>> commiting to git\n" git commit -am "$gen" exit_with_new_shell From deba4793f7e37e19820f743722a0cfaf96729f4c Mon Sep 17 00:00:00 2001 From: ranomier Date: Mon, 27 Jan 2025 15:54:29 +0100 Subject: [PATCH 2/3] added options and one to only switch --- nswitch | 78 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 26 deletions(-) diff --git a/nswitch b/nswitch index bf6e36b..4c9f471 100755 --- a/nswitch +++ b/nswitch @@ -14,6 +14,8 @@ exit_with_new_shell() { # check if already in directory [[ "$INITIAL_PWD" = "$PROJECT" ]] && printf '>>> already in directory\n' && exit 0 + cd "$PROJECT" || exit 1 + printf '\n' printf '>>> opening a new \"%s\" shell\n' "$(basename "$SHELL")" printf ' cwd: %s\n' "$(pwd)" @@ -21,35 +23,59 @@ exit_with_new_shell() { exit 0 } -cd "$PROJECT" || exit 1 -nvim +quick_edit() { + 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 + # 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" + # only then do auto formating + printf ">>> auto formating ..." + nix fmt . &> /dev/null + printf " DONE!\n" -# and then show the user a diff -git diff -U0 "$GIT_PATTERN" # as a seperate command so we get nice colors and pager + # 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" + printf "<<< " && read -r YESNO + if ! [[ "${YESNO,,}" == "y" ]]; then + exit_with_new_shell + fi + + printf ">>> Add everything to git staging so nix can find it\n" + git add "$GIT_PATTERN" + + printf ">>> Rebuilding NixOS\n" + sudo nixos-rebuild switch | tee nixos-switch.log || ( + grep --color error nixos-switch.log && false) + gen=$(nixos-rebuild list-generations | grep current) + + printf ">>> commiting to git\n" + git commit -am "$gen" -printf ">>> Do you want to rebuild NixOS? [y/N]\n" -printf "<<< " && read -r YESNO -if ! [[ "${YESNO,,}" == "y" ]]; then exit_with_new_shell +} + + +help_msg() { + printf -- ' without arguments start the main loop\n' + printf -- '--help | -h -> show this message\n' + printf -- '--new-shell-in-project | -s -> show this message\n' +} + + + +if [[ -z "$1" ]]; then + quick_edit +elif [[ "$1" = "--help" || "$1" = "-h" ]]; then + help_msg +elif [[ "$1" = "--new-shell-in-project" || "$1" = "-s" ]]; then + exit_with_new_shell +else + help_msg + printf "=================\n" + printf "didn't recognise: %s\n" "$1" + exit 1 fi - -printf ">>> Add everything to git staging so nix can find it\n" -git add "$GIT_PATTERN" - -printf ">>> Rebuilding NixOS\n" -sudo nixos-rebuild switch | tee nixos-switch.log || ( - grep --color error nixos-switch.log && false) -gen=$(nixos-rebuild list-generations | grep current) - -printf ">>> commiting to git\n" -git commit -am "$gen" - -exit_with_new_shell From 0093a34d48d938803f3e367bcd21738e33d9b4eb Mon Sep 17 00:00:00 2001 From: ranomier Date: Mon, 27 Jan 2025 15:55:52 +0100 Subject: [PATCH 3/3] added back passing arguemnts. It seems to not crash anymore, but seems to not care about command line parameter --- rustdesk_profile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rustdesk_profile b/rustdesk_profile index c4bcec3..5aee37e 100755 --- a/rustdesk_profile +++ b/rustdesk_profile @@ -21,7 +21,4 @@ mkdir -p "$XDG_CONFIG_HOME" printf 'Using profile: %s\n' "$XDG_CONFIG_HOME" #exit 0 -# As of rustdesk 1.1.9 giving rustdesk unknown arguments crashes it with an address boundary error. -# (At least on my machines) -# Thats why we are calling rustdesk without arguments, until thats solved -rustdesk #"${*:2}" +rustdesk "${*:2}"