From 2154834ff6a03698b83e224b9155379a4c22918f Mon Sep 17 00:00:00 2001 From: lverweijen Date: Tue, 8 Mar 2016 19:55:40 +0100 Subject: Support 256 colours if available --- ranger/data/scope.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index afaf131f..669d1e34 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -91,8 +91,15 @@ esac case "$mimetype" in # Syntax highlight for text files: text/* | */xml) - try safepipe highlight --out-format=ansi "$path" && { dump | trim; exit 5; } - try safepipe pygmentize "$path" && { dump | trim; exit 5; } + if [ "$(tput colors)" -ge 256 ]; then + pygmentize_format=terminal256 + highlight_format=xterm256 + else + pygmentize_format=terminal + highlight_format=ansi + fi + try safepipe highlight --out-format=${highlight_format} "$path" && { dump | trim; exit 5; } + try safepipe pygmentize -f ${pygmentize_format} "$path" && { dump | trim; exit 5; } exit 2;; # Ascii-previews of images: image/*) -- cgit 1.4.1-2-gfad0