Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fuzzy find (fzf) to show file from history in Git
# Show file from Git tree at a certain point in the history
function hist() {
local ref=$1
local query=$2
if [ -z $ref ]; then
echo "Please specify a ref";
return;
fi
local file=$(git ls-tree -r --name-only $ref | fzf --query="$query")
if [ -z $file ]; then
return;
fi
git show "$ref":"$file" | pygmentize -f terminal256 -O style=native -g | less -Ri
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.