Files
dotfiles/.config/zsh/autoload/git/git-abort
Julian Prein 740c0b2fd7 git: Add git-abort & git-continue
I find typing `git {rebase,merge,...} --{continue,abort}` a bit
annoying, since it is a lot of typing. I have added an alias for `rebase
--continue` (grc), but the problem remained for the other commands.

Add a script that continues or aborts the ongoing process by detecting
it automatically.
2025-06-19 14:03:17 +02:00

32 lines
697 B
Bash
Executable File

#!/usr/bin/env zsh
# SPDX-License-Identifier: MIT
# Copyright (c) 2025 Julian Prein
#
# Abort or continue the current rebase/merge/cherry-pick/revert/am (execute as
# git-abort or git-continue).
emulate -L zsh -o err_return -o no_unset
local gitdir
gitdir="$(git rev-parse --git-dir)" || return
local flag="${${0:t}#git-}"
local cmd
if [[ -e $gitdir/REBASE_HEAD ]]; then
cmd=rebase
elif [[ -e $gitdir/MERGE_HEAD ]]; then
cmd=merge
elif [[ -e $gitdir/CHERRY_PICK_HEAD ]]; then
cmd=cherry-pick
elif [[ -e $gitdir/REVERT_HEAD ]]; then
cmd=revert
elif [[ -e $gitdir/rebase-apply/applying ]]; then
cmd=am
else
printf "Nothing to %s at the moment\n" "$flag"
return 1
fi
git "$cmd" "--$flag"