diff options
author | hut <hut@lepus.uberspace.de> | 2015-10-09 13:59:37 +0200 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2015-10-15 11:54:14 +0200 |
commit | 82ae8743adf352387dd1f3996af1dbe5a25a02a3 (patch) | |
tree | 2079c18a21f28957e373e8f1e4bbe3da41f88b13 /ranger | |
parent | 8d774594cd2006beeff06b65755579b9b46ca44d (diff) | |
download | ranger-82ae8743adf352387dd1f3996af1dbe5a25a02a3.tar.gz |
scope.sh: generalize "highlight" function, add pygmentize
Diffstat (limited to 'ranger')
-rwxr-xr-x | ranger/data/scope.sh | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 19404019..add6fbc8 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -44,7 +44,7 @@ dump() { /bin/echo "$output"; } trim() { head -n "$maxln"; } # wraps highlight to treat exit code 141 (killed by SIGPIPE) as success -highlight() { command highlight "$@"; test $? = 0 -o $? = 141; } +safepipe() { "$@"; test $? = 0 -o $? = 141; } # Image previews, if enabled in ranger. if [ "$preview_images" = "True" ]; then @@ -91,7 +91,9 @@ esac case "$mimetype" in # Syntax highlight for text files: text/* | */xml) - try highlight --out-format=ansi "$path" && { dump | trim; exit 5; } || exit 2;; + try safepipe highlight --out-format=ansi "$path" && { dump | trim; exit 5; } + try safepipe pygmentize "$path" && { dump | trim; exit 5; } + exit 2;; # Ascii-previews of images: image/*) img2txt --gamma=0.6 --width="$width" "$path" && exit 4 || exit 1;; |