git-sign() { case $# in "0") range=HEAD ;; "1") range=$1 ;; * ) echo "too many arguments" 1>&2; return 1 ;; esac # In git-2.8.4, it should be possible to drop the -i option , # along with the override of EDITOR: # https://git.kernel.org/cgit/git/git.git/commit/?h=next&id=78ec240020db4bdd773830f3d41f4b4bdf9a4e2d EDITOR=true git rebase -i "$range" --exec "git commit --amend --no-edit --gpg-sign" \ || git rebase --abort }