Skip to content

Instantly share code, notes, and snippets.

@stecman
Created February 27, 2018 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stecman/71b887b9f043c2e705386a911865ad98 to your computer and use it in GitHub Desktop.
Save stecman/71b887b9f043c2e705386a911865ad98 to your computer and use it in GitHub Desktop.
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