From 82ae8743adf352387dd1f3996af1dbe5a25a02a3 Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 9 Oct 2015 13:59:37 +0200 Subject: scope.sh: generalize "highlight" function, add pygmentize --- ranger/data/scope.sh | 6 ++++-- 1 file 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;; -- cgit 1.4.1-2-gfad0