Do not preview binary files

This commit is contained in:
Junegunn Choi 2017-01-23 10:28:08 +09:00
parent 3e8ac82cbb
commit f54ec7caf1
No known key found for this signature in database
GPG key ID: 254BC280FEF9C627
2 changed files with 10 additions and 0 deletions

View file

@ -27,6 +27,11 @@ unless File.readable? path
exit 1
end
if `file --mime "#{file}"` =~ /binary/
puts "#{file} is a binary file"
exit 0
end
center = (center || 0).to_i
height = File.readable?('/dev/tty') ? `stty size < /dev/tty`.split.first.to_i : 40
height /= 2 if split

View file

@ -22,6 +22,11 @@ if [ ! -r "$FILE" ]; then
exit 1
fi
if [[ "$(file --mime "$FILE")" =~ binary ]]; then
echo "$1 is a binary file"
exit 0
fi
if [ -z "$CENTER" ]; then
CENTER=1
fi