From 24999c4776f0757ec785522c39e470e4b5fa30f5 Mon Sep 17 00:00:00 2001 From: bretello Date: Fri, 8 Oct 2021 23:49:39 +0200 Subject: [PATCH] zsh: add git-fixup command (git fixup) --- aliases.sh | 3 +-- functions.sh | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/aliases.sh b/aliases.sh index cd12369..84bdd51 100755 --- a/aliases.sh +++ b/aliases.sh @@ -66,8 +66,7 @@ alias gl5='git log -n 5' alias pvim='poetry run vim' alias gs='git status' -alias gcf='git commit --fixup=HEAD' -alias gcaf='git commit -a --fixup=HEAD' +alias gcfx='git-fixup' alias gls="git log --pretty=oneline --abbrev-commit" # gls: Git Log Short alias watcha='watch ' # note the space after watch. This makes watch work with aliases diff --git a/functions.sh b/functions.sh index 0123394..4381921 100755 --- a/functions.sh +++ b/functions.sh @@ -306,7 +306,6 @@ function fgitlog() { git log --oneline $@ | fzf --multi --preview 'git -p show --color=always {+1}' --preview-window=right,60% } -compdef _git fgitlog=git-log git-commit-show() { git log --graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" | fzf --ansi --no-sort --reverse --tiebreak=index --preview \ @@ -322,6 +321,12 @@ git-commit-show() { --preview-window=right:60% } +compdef __git_recent_commits git-fixup +git-fixup() { + git commit --fixup=$1 + git -c sequence.editor=true rebase --interactive --autosquash $1^ +} + # dotfiles user functions if [[ -f $HOME/.dotfiles_functions ]]; then source "$HOME/.dotfiles_functions"