diff --git a/.config/zsh/autoload/git/git-signoff b/.config/zsh/autoload/git/git-signoff new file mode 100755 index 0000000..49d9a35 --- /dev/null +++ b/.config/zsh/autoload/git/git-signoff @@ -0,0 +1,21 @@ +#!/usr/bin/env zsh +## Author: Julian Prein +## Created: 2022-03-29 +## +## Signoff range of commits + +# Exit if not in git repo +git rev-parse || return + +# Exit if no arguments were given +[[ $# -gt 0 ]] || return + +# Signoff all commits +env GIT_SEQUENCE_EDITOR="sed -Ei 's/^p(ick)?/e/'" git rebase -i "$@" || return + +while git rebase --show-current-patch &>/dev/null; do + git commit --amend --signoff --no-edit --no-verify + git rebase --continue +done + +return 0 diff --git a/.config/zsh/zshrc.d/20-completion.zsh b/.config/zsh/zshrc.d/20-completion.zsh index 44207c4..77d6999 100644 --- a/.config/zsh/zshrc.d/20-completion.zsh +++ b/.config/zsh/zshrc.d/20-completion.zsh @@ -39,6 +39,7 @@ compdef nvim-man=man compdef _git-log glog compdef _git-checkout git-checkout-worktree compdef _git-commit git-commit-last-msg +compdef _git-rebase git-signoff # Run git's completion once to avoid a `command not found` error when using the # completion functions on other programs without having completed something for # git before in the same session.