Last active
October 16, 2022 14:18
-
-
Save maguroguma/249671a398da34ddcc87f2196d88d66d to your computer and use it in GitHub Desktop.
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
# unique MRC(most recently checkouted, like MRU) checkouted branchs or commit hashs -> branch name or commit hash | |
_gm() { | |
is_in_git_repo || return | |
git --no-pager reflog | awk '$3 == "checkout:" && /moving from/ {print $8}' | uniq | \ | |
awk ' | |
BEGIN { memo[0]=""; results[0]=""; } { if(!($0 in memo)) | |
{ memo[$0] = 1; results[length(results)] = $0; } } | |
END { for(i=1; i<length(results); i++) print results[i] } | |
' | \ | |
fzf-down -m --preview 'git show --color=always {1}' --prompt="refs> " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment