diff options
author | lverweijen <lverweijen> | 2016-03-08 19:55:40 +0100 |
---|---|---|
committer | lverweijen <lverweijen> | 2016-03-08 19:55:40 +0100 |
commit | 2154834ff6a03698b83e224b9155379a4c22918f (patch) | |
tree | 6b69028c5bbb9d2ab3c2abd2276dc3cf8d03d548 /ranger | |
parent | 7ee4b45bd2619fb07c9b139940003224bedb1de3 (diff) | |
download | ranger-2154834ff6a03698b83e224b9155379a4c22918f.tar.gz |
Support 256 colours if available
Diffstat (limited to 'ranger')
-rwxr-xr-x | ranger/data/scope.sh | 11 |
1 files 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/*) |