mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-10 23:00:39 +02:00
feat: add gf shortcut that does an interactive git fixup
This commit is contained in:
parent
76feb121e2
commit
c92aadf4cd
1 changed files with 19 additions and 0 deletions
|
@ -66,6 +66,25 @@
|
|||
gca = "git commit -v -S --amend";
|
||||
gcl = "git clone";
|
||||
gcr = "git commit-reuse-message -v -S";
|
||||
gf = lib.getExe (pkgs.writeShellApplication {
|
||||
name = "git-fixup-fzf";
|
||||
runtimeInputs = [pkgs.fzf pkgs.gnugrep];
|
||||
text = ''
|
||||
if ! commit=$(git log --graph --color=always --format="%C(auto)%h%d %s %C(reset)%C(bold)%cr" "$@" \
|
||||
| fzf --ansi --multi --no-sort --reverse --print-query --expect=ctrl-d --toggle-sort=\`); then
|
||||
echo aborted
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sha=$(grep -o '^[^a-z0-9]*[a-z0-9]\{7\}[a-z0-9]*' <<< "$commit" | grep -o '[a-z0-9]\{7\}[a-z0-9]*')
|
||||
if [[ -z "$sha" ]]; then
|
||||
echo "Found no checksum for selected commit. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git fixup "$sha" "$@"
|
||||
'';
|
||||
});
|
||||
gp = "git push";
|
||||
gpf = "git push --force";
|
||||
gs = "git s";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue