Created
August 1, 2019 16:07
-
-
Save OliverJAsh/cb151abe8d46f067b6f48b9dc6a84600 to your computer and use it in GitHub Desktop.
git-pamlog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://junegunn.kr/2016/07/fzf-git/ | |
# https://hackernoon.com/be-125-more-efficient-with-git-60556a1ce971 | |
# https://github.com/fcsonline/dotfiles/blob/master/git/gitconfig | |
# https://github.com/junegunn/fzf/wiki/Examples#git | |
# TODO: incorporate fix into this? | |
# TODO: select commits for editing, generate rebase from that | |
function view () { | |
# _gitLogLineToHash="echo {} | awk '{ print $1 }'" | |
_gitLogLineToHash="echo {} | grep -o '[a-f0-9]\{9\}'" | |
# _gitLogLineToHash="echo {} | grep -o '[a-f0-9]\{9\}' | head -1" | |
_viewGitLogLine="$_gitLogLineToHash | xargs -I % sh -c 'git show --color=always %'" | |
# _viewGitLogLine="git show $($_gitLogLineToHash)" | |
git log --oneline --color=always --decorate "$@" | | |
fzf --ansi --reverse \ | |
`# When searching, we want to preseve the original log order.` \ | |
--no-sort \ | |
`# Workaround for https://github.com/junegunn/fzf/issues/1567 and https://github.com/junegunn/fzf/issues/1568` \ | |
--no-mouse \ | |
--preview="$_viewGitLogLine" \ | |
--preview-window=down:50% \ | |
--bind="enter:execute:($_viewGitLogLine > /dev/tty)" \ | |
--expect=ctrl-r,ctrl-f | |
} | |
function run () { | |
OUT=($(view "$@")) | |
KEY=${OUT[0]} | |
REF=${OUT[1]} | |
[ -n "$REF" ] && case "$KEY" in | |
ctrl-r) git rebase --interactive $REF ;; | |
ctrl-f) git fixit $REF ;; | |
esac | |
} | |
run "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment