Do not preview binary files
This commit is contained in:
parent
3e8ac82cbb
commit
f54ec7caf1
2 changed files with 10 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue