1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat: add gf shortcut that does an interactive git fixup

This commit is contained in:
oddlama 2024-06-20 17:47:20 +02:00
parent 76feb121e2
commit c92aadf4cd
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A

View file

@ -66,6 +66,25 @@
gca = "git commit -v -S --amend"; gca = "git commit -v -S --amend";
gcl = "git clone"; gcl = "git clone";
gcr = "git commit-reuse-message -v -S"; 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"; gp = "git push";
gpf = "git push --force"; gpf = "git push --force";
gs = "git s"; gs = "git s";