From 9cd3d2df9df27b2d1b73a60e82743d34f036942f Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Mon, 10 Apr 2023 18:31:48 +0200 Subject: [PATCH] bin: lil improvements --- .config/shell/functions | 2 +- .local/bin/scripts/chexec | 3 +++ .local/bin/scripts/git-l | 5 +---- .local/bin/scripts/git-p | 5 ++++- 4 files changed, 9 insertions(+), 6 deletions(-) create mode 100755 .local/bin/scripts/chexec diff --git a/.config/shell/functions b/.config/shell/functions index d0e899e..a73b54e 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -506,7 +506,7 @@ fi lowercase() { #$(which perl-rename || echo rename) -iv 'y/A-Z /a-z-/' "$@" - find "$@" -exec sh -c 'mv -iv {} "$(echo {} | tr "A-Z " "a-z-" | sed "s|---|_|;s|\.-|.|")" 2>/dev/null' \; + find "$@" -exec sh -c 'mv -iv "{}" "$(echo "{}" | tr "A-Z " "a-z-" | sed "s|---|_|;s|\.-|.|")" 2>/dev/null' \; } # TODO replace cp by rsync, automatically use compression for remote transfers diff --git a/.local/bin/scripts/chexec b/.local/bin/scripts/chexec new file mode 100755 index 0000000..37b913d --- /dev/null +++ b/.local/bin/scripts/chexec @@ -0,0 +1,3 @@ +#!/bin/sh -ex +# Set exec flag on all files that should be executable +find -maxdepth 4 -name "*.sh" "$@" -exec chmod +x {} + diff --git a/.local/bin/scripts/git-l b/.local/bin/scripts/git-l index f098fdf..92795d2 100755 --- a/.local/bin/scripts/git-l +++ b/.local/bin/scripts/git-l @@ -1,7 +1,4 @@ #!/bin/bash git rev-parse @{upstream} >/dev/null 2>&1 || git branch --set-upstream-to=@{push} -git pull --rebase --autostash "$@" 2> >(head -4 >&2) || - { test -e $(git rev-parse --git-path rebase-merge) && - printf "\e[31;1mError - aborting rebase!\e[0m\n" >&2 && - git rebase --abort; } +git pull --rebase --autostash "$@" 2> >(head -4 >&2) diff --git a/.local/bin/scripts/git-p b/.local/bin/scripts/git-p index ae0eaf2..748899f 100755 --- a/.local/bin/scripts/git-p +++ b/.local/bin/scripts/git-p @@ -1,5 +1,8 @@ #!/bin/sh -git-l +git-l || + { test -e $(git rev-parse --git-path rebase-merge) && + printf "\e[31;1mError - aborting rebase!\e[0m\n" >&2 && + git rebase --abort; } if git rev-parse @{upstream} >/dev/null 2>&1 then git push "$@" else git push --set-upstream "$@"