From d81fd432126022c2c03d80b56b8f3c2ef43f450c Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 27 Jul 2021 13:20:42 +0200 Subject: [PATCH] bin: fix git-rmbranch --- .config/shell/functions | 1 - .local/bin/scripts/git-rmbranch | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.config/shell/functions b/.config/shell/functions index 6d43e30..704976a 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -101,7 +101,6 @@ edconf() { mkdir -p "$conf_cache_dir" touch "$conf_cache" sel=$(listconf | fzf -1 -0 --tiebreak=end,length --preview '$(test -r "{}" || echo "sudo") bat --color=always --style=numbers --line-range :200 {}' --query="$1" --history "$conf_cache_dir/searches") - # | xargs file | grep text | cut -d':' -f1 # this filters out non-text files, but it's ridiculously slow test "$sel" && ((echo "$sel" | cat - "$conf_cache" | head -30 >"$conf_tmp" && mv "$conf_tmp" "$conf_cache") & edit "$sel") } diff --git a/.local/bin/scripts/git-rmbranch b/.local/bin/scripts/git-rmbranch index 7db7130..f4e550c 100755 --- a/.local/bin/scripts/git-rmbranch +++ b/.local/bin/scripts/git-rmbranch @@ -2,6 +2,6 @@ # Removes the given branch locally and remotely. # With no argument it switches to the default branch and deletes the current branch. branch=${1:-$(git curbranch)} -echo "${@:-$branch}" | sed 's/\([^ ]\+\)/\1@{push}/g' | xargs git rev-parse --abbrev-ref --revs-only | sed 's/\// /' | xargs git push -d -test $1 || git checkout main 2>/dev/null || git checkout master || git checkout $(cat .git/refs/remotes/origin/HEAD | cut -d'/' -a) +echo "${@:-$branch}" | sed 's/\([^ ]\+\)/\1@{push}/g' | xargs git rev-parse --abbrev-ref --revs-only | sed 's/\// /' | xargs --no-run-if-empty git push -d +test -n "$1" || git checkout main || git checkout master || git checkout $(cat "$(git rev-parse --git-path "refs/remotes/origin/HEAD")" | sed 's|.*/||') git branch -D "${@:-$branch}"