Skip to content

Commit

Permalink
preview files in history (^R)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarrekNozka committed Feb 23, 2022
1 parent 475e6d0 commit b27823e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions fzf--previewer.zsh
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#!/usr/bin/env bash
#!/usr/bin/env zsh

FILE_PATH=$1

bat=`/usr/bin/which bat || echo batcat`

if [ -d "$1" ]; then
tree --du -C -L 2 "$FILE_PATH"
elif ! [ -f "$1" ]; then
echo $1 | read -A tokens
for token in $tokens; do
if [ -f $token ]; then
$bat --style=numbers --color=always --line-range :222 $token
fi
done
else
FILE_MIME=$(file --mime "$FILE_PATH")
filename=$(basename -- "$FILE_PATH")
Expand Down Expand Up @@ -63,8 +72,7 @@ else
echo "$FILE_MIME"
hexyl -n 4kB "$FILE_PATH" && exit 0
else
cat --style=numbers --color=always --line-range :222 $1 && exit 0
batcat --style=numbers --color=always --line-range :222 $1 && exit 0
$bat --style=numbers --color=always --line-range :222 $1 && exit 0
fi
exit 1;;
esac
Expand Down

0 comments on commit b27823e

Please sign in to comment.