Do not preview binary files

This commit is contained in:
Junegunn Choi
2017-01-23 10:28:08 +09:00
parent 3e8ac82cbb
commit f54ec7caf1
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