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.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
# the right directory, as shell commands in git aliases are executed
|
||||
# from the top-level directory of the repository.
|
||||
|
||||
abort = "!git-zsh-autoload abort"
|
||||
autosquash = -c sequence.editor=/bin/true rebase -i --autosquash
|
||||
autofixup= autosquash
|
||||
c = commit
|
||||
@@ -17,6 +18,7 @@
|
||||
cow = checkout-worktree
|
||||
co = checkout
|
||||
commit-last-msg = "!git-zsh-autoload commit-last-msg"
|
||||
continue = "!git-zsh-autoload continue"
|
||||
clm = commit-last-msg
|
||||
last-msg = commit-last-msg
|
||||
recommit = commit-last-msg --no-edit
|
||||
|
||||
31
.config/zsh/autoload/git/git-abort
Executable file
31
.config/zsh/autoload/git/git-abort
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/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"
|
||||
1
.config/zsh/autoload/git/git-continue
Symbolic link
1
.config/zsh/autoload/git/git-continue
Symbolic link
@@ -0,0 +1 @@
|
||||
git-abort
|
||||
Reference in New Issue
Block a user