shell/fzf: add bin/fzf-git-{log,sha}

This commit is contained in:
Henrik Lissner 2017-04-25 17:18:29 -04:00
parent 8f641a3149
commit 5a65cc9960
2 changed files with 21 additions and 0 deletions

10
shell/fzf/bin/fzf-git-log Executable file
View file

@ -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"

11
shell/fzf/bin/fzf-git-sha Executable file
View file

@ -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/ .*//")