Skip to content

Instantly share code, notes, and snippets.

@maguroguma
Last active October 16, 2022 14:18
Show Gist options
  • Save maguroguma/249671a398da34ddcc87f2196d88d66d to your computer and use it in GitHub Desktop.
Save maguroguma/249671a398da34ddcc87f2196d88d66d to your computer and use it in GitHub Desktop.
# 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