diff options
author | hut <hut@lavabit.com> | 2010-06-22 01:44:48 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-06-22 01:44:48 +0200 |
commit | 356726c41d5f7a95fdf60ed867f05d2d10bff70a (patch) | |
tree | fa08619994199f2c0321b95b9130aa041e128e87 | |
parent | 48a13dcdb31313d74e71028a32e19041f3a7f76c (diff) | |
download | ranger-356726c41d5f7a95fdf60ed867f05d2d10bff70a.tar.gz |
data/scope.sh: improved, commented
-rwxr-xr-x | ranger/data/scope.sh | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 998476dc..ad14f5e5 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -1,21 +1,30 @@ #!/bin/bash -# This script is responsible to generate the previews for ranger. + +# This script is called whenever you preview a file. +# Its output is used as the preview. ANSI color codes are supported. + +# Meaning of exit codes: +# code | meaning | action of ranger +# -----+------------+------------------------------------------- +# 0 | success | display stdout as preview +# 1 | no preview | display no preview at all + + mimetype=$(file --mime-type -Lb "$1") -basetype=$(echo "$mimetype" | grep -o '^[^/]\+') extension=$(echo "$1" | grep '\.' | grep -o '[^.]\+$') -case "$basetype" in - text) - highlight --ansi "$1" || cat "$1" +case "$mimetype" in + text/*) + highlight --ansi "$1" || cat "$1" || exit 1 exit 0;; - image) + image/*) img2txt "$1" || exit 1 exit 0;; esac case "$extension" in zip|gz) - atool -l "$1" + atool -l "$1" || exit 1 exit 0;; esac |