Skip to content

Instantly share code, notes, and snippets.

@tamphh tamphh/file_preview
Last active Jul 9, 2019

Embed
What would you like to do?
Bash script to preview files with bat for fzf
#!/bin/bash
file="$1"
[[ $(file --mime "$file") =~ binary ]] &&
echo "$file" is a binary file ||
(bat --style=numbers --color=always "$file" ||
highlight -O ansi -l "$file" ||
coderay "$file" ||
rougify "$file" ||
cat "$file") 2> /dev/null | head -500
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.