diff --git a/shell/fzf/bin/fzf-git-log b/shell/fzf/bin/fzf-git-log new file mode 100755 index 00000000..bc4756de --- /dev/null +++ b/shell/fzf/bin/fzf-git-log @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +git log --graph --color=always \ + --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" | +fzf --ansi --no-sort --reverse --tiebreak=index --bind=ctrl-s:toggle-sort \ + --bind "ctrl-m:execute: + (grep -o '[a-f0-9]\{7\}' | head -1 | + xargs -I % sh -c 'git show --color=always % | less -R') << 'FZF-EOF' + {} +FZF-EOF" diff --git a/shell/fzf/bin/fzf-git-sha b/shell/fzf/bin/fzf-git-sha new file mode 100755 index 00000000..f3b547d1 --- /dev/null +++ b/shell/fzf/bin/fzf-git-sha @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# Retrieves a git commit's SHA, useful for a variety of git commands. +# +# Examples: +# + git checkout `fzf-git-sha` +# + git commit --fixup `fzf-git-sha` + +commits=$(git log --color=always --pretty=oneline --abbrev-commit --reverse) && + commit=$(echo "$commits" | fzf --tac +s +m -e --ansi --reverse) && + echo -n $(echo "$commit" | sed "s/ .*//")