From d8c62fa4ee9210ae7fa894150adad65340088865 Mon Sep 17 00:00:00 2001 From: ranomier Date: Sat, 14 Dec 2024 14:22:45 +0100 Subject: [PATCH 1/9] do nothing if git diff is empty --- nswitch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nswitch b/nswitch index 7f5e213..07c4ece 100755 --- a/nswitch +++ b/nswitch @@ -12,7 +12,8 @@ printf ">>> auto formating ..." nix fmt . &> /dev/null printf " DONE!\n" -git diff -U0 # "*.nix" +[ -z "$(git diff -U0)" ] && echo ">>> no changes, exiting ..." && exit 0 +git diff -U0 # "*.nix" # 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 From d12da385fd0559b18bdcfdc9fe2a62ff720dba00 Mon Sep 17 00:00:00 2001 From: ranomier Date: Sat, 14 Dec 2024 15:47:13 +0100 Subject: [PATCH 2/9] start shell with changed directory --- nswitch | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nswitch b/nswitch index 07c4ece..ed2c3ec 100755 --- a/nswitch +++ b/nswitch @@ -12,7 +12,7 @@ printf ">>> auto formating ..." nix fmt . &> /dev/null printf " DONE!\n" -[ -z "$(git diff -U0)" ] && echo ">>> no changes, exiting ..." && exit 0 +[ -z "$(git diff -U0)" ] && echo ">>> no changes, exiting ..." && "$SHELL" && exit 0 git diff -U0 # "*.nix" # as a seperate command so we get nice colors and pager printf ">>> Do you want to rebuild NixOS? [y/N]\n" @@ -27,3 +27,5 @@ sudo nixos-rebuild switch | tee nixos-switch.log || ( grep --color error nixos-switch.log && false) gen=$(nixos-rebuild list-generations | grep current) git commit -am "$gen" + +"$SHELL" From 2024f587ed7c17152426430911a48249d73c3761 Mon Sep 17 00:00:00 2001 From: ranomier Date: Sat, 14 Dec 2024 15:54:11 +0100 Subject: [PATCH 3/9] even though i have set -e let's make sure cd can fail --- nswitch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nswitch b/nswitch index ed2c3ec..2b20694 100755 --- a/nswitch +++ b/nswitch @@ -5,7 +5,7 @@ set -E -o pipefail shopt -s failglob export LC_ALL=C.UTF8 -cd ~/Projects/NixOS/ +cd ~/Projects/NixOS/ || exit 1 nvim printf ">>> auto formating ..." From c1b053b67d036a9b90325d49d088e96bb288e395 Mon Sep 17 00:00:00 2001 From: ranomier Date: Sat, 14 Dec 2024 17:53:38 +0100 Subject: [PATCH 4/9] fix cd --- dlp-trnsrpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlp-trnsrpt b/dlp-trnsrpt index f36619f..cc6d3b1 100755 --- a/dlp-trnsrpt +++ b/dlp-trnsrpt @@ -6,7 +6,7 @@ export LC_ALL=C.UTF8 TEMP_FOLDER='/tmp/dlp-trnsrpt' mkdir -p "$TEMP_FOLDER" -cd "$TEMP_FOLDER" +cd "$TEMP_FOLDER" || exit 1 yt-dlp --write-auto-sub --sub-langs 'en.*,.*orig' --convert-subs=srt --skip-download "$*" nvim "$TEMP_FOLDER"/*-orig* From 4f1e35ebadee296c2b7611ab6bbe6d38ecc7544a Mon Sep 17 00:00:00 2001 From: ranomier Date: Sat, 14 Dec 2024 17:54:12 +0100 Subject: [PATCH 5/9] start shell with the cd folder --- dlp-trnsrpt | 1 + 1 file changed, 1 insertion(+) diff --git a/dlp-trnsrpt b/dlp-trnsrpt index cc6d3b1..1d76669 100755 --- a/dlp-trnsrpt +++ b/dlp-trnsrpt @@ -10,3 +10,4 @@ cd "$TEMP_FOLDER" || exit 1 yt-dlp --write-auto-sub --sub-langs 'en.*,.*orig' --convert-subs=srt --skip-download "$*" nvim "$TEMP_FOLDER"/*-orig* +"$SHELL" From aeb8f16a9404c9a38e0b64a6c37d287f8168aa39 Mon Sep 17 00:00:00 2001 From: ranomier Date: Sat, 14 Dec 2024 17:55:58 +0100 Subject: [PATCH 6/9] remove mixed array and string --- nstore-find | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nstore-find b/nstore-find index 0a5820d..51fed54 100755 --- a/nstore-find +++ b/nstore-find @@ -4,4 +4,4 @@ set -E -o pipefail shopt -s failglob export LC_ALL=C.UTF8 -find /nix/store/ -maxdepth 1 -iname '*'"$@"'*' +find /nix/store/ -maxdepth 1 -iname '*'"$*"'*' From c7f70c6a118446688f8abe4b7cc185e8e81cd6c2 Mon Sep 17 00:00:00 2001 From: ranomier Date: Sat, 14 Dec 2024 17:59:04 +0100 Subject: [PATCH 7/9] make linter happy --- rustdesk_profile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustdesk_profile b/rustdesk_profile index 332adff..c4bcec3 100755 --- a/rustdesk_profile +++ b/rustdesk_profile @@ -18,7 +18,7 @@ fi # make sure profile folder for config exists. export XDG_CONFIG_HOME="$HOME/.config/rustdesk_${RUSTDESK_PROFILE}" mkdir -p "$XDG_CONFIG_HOME" -printf "Using profile: $XDG_CONFIG_HOME\n" +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. From 24c6fa4a7fb7160e0cfc8ef3703291ef1cea8c4e Mon Sep 17 00:00:00 2001 From: ranomier Date: Sat, 14 Dec 2024 20:20:46 +0100 Subject: [PATCH 8/9] made it nicer and default tool is now crop --- screenshot | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/screenshot b/screenshot index a2af902..cb04e68 100755 --- a/screenshot +++ b/screenshot @@ -4,4 +4,9 @@ set -E -o pipefail shopt -s failglob export LC_ALL=C.UTF8 -grim -g "$(slurp -o -r -c '#ff0000ff')" - | satty --filename - --fullscreen --output-filename ~/Media/Pictures/Screenshots/satty-$(date '+%Y%m%d-%H:%M:%S').png +grim -g "$(slurp -o -r -c '#ff0000ff')" - \ + | satty \ + --filename - \ + --fullscreen \ + --initial-tool "crop" \ + --output-filename "$HOME/Media/Pictures/Screenshots/satty-$(date '+%Y%m%d-%H:%M:%S').png" From 15bba163f869a2c6b889a87bd61bb5c77e57cb93 Mon Sep 17 00:00:00 2001 From: ranomier Date: Sat, 14 Dec 2024 20:35:04 +0100 Subject: [PATCH 9/9] pretty pretty --- nswitch | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/nswitch b/nswitch index 2b20694..12fd592 100755 --- a/nswitch +++ b/nswitch @@ -5,6 +5,14 @@ set -E -o pipefail shopt -s failglob export LC_ALL=C.UTF8 +exit_with_new_shell() { + printf '\n' + printf '>>> opening a new \"%s\" shell\n' "$(basename "$SHELL")" + printf '>>> cwd: %s\n' "$(pwd)" + "$SHELL" + exit 0 +} + cd ~/Projects/NixOS/ || exit 1 nvim @@ -12,14 +20,13 @@ printf ">>> auto formating ..." nix fmt . &> /dev/null printf " DONE!\n" -[ -z "$(git diff -U0)" ] && echo ">>> no changes, exiting ..." && "$SHELL" && exit 0 +[ -z "$(git diff -U0)" ] && echo ">>> no changes, exiting ..." && exit_with_new_shell git diff -U0 # "*.nix" # 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 - printf ">>> Exiting ...\n" - exit 1 + exit_with_new_shell fi printf ">>> Rebuilding NixOS\n" @@ -28,4 +35,4 @@ sudo nixos-rebuild switch | tee nixos-switch.log || ( gen=$(nixos-rebuild list-generations | grep current) git commit -am "$gen" -"$SHELL" +exit_with_new_shell