Created
February 27, 2018 04:04
-
-
Save stecman/71b887b9f043c2e705386a911865ad98 to your computer and use it in GitHub Desktop.
Fuzzy find (fzf) to show file from history in Git
This file contains 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
# 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