From 67e0ef7aa6a494b2357c64a204214f7b19fb52e7 Mon Sep 17 00:00:00 2001 From: "GIL B. Chan" Date: Sun, 7 Apr 2019 18:48:22 +0900 Subject: edit colorize plugin: add `-f terminal` option The option (`pygmentize -f terminal <...>`) lets pygments use terminal color scheme. Otherwise, it would use its default colors, which might be unbalanced with that of terminal (e.g. not harmonious with background color of terminal). --- plugins/colorize/colorize.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/colorize') diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index 8eede9a94..d52e95c49 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -9,7 +9,7 @@ colorize_via_pygmentize() { # pygmentize stdin if no arguments passed if [ $# -eq 0 ]; then - pygmentize -g + pygmentize -f terminal -g return $? fi @@ -20,9 +20,9 @@ colorize_via_pygmentize() { do lexer=$(pygmentize -N "$FNAME") if [[ $lexer != text ]]; then - pygmentize -l "$lexer" "$FNAME" + pygmentize -f terminal -l "$lexer" "$FNAME" else - pygmentize -g "$FNAME" + pygmentize -f terminal -g "$FNAME" fi done } -- cgit v1.2.3-70-g09d2 From 66e2284a08f86e5dcf661e3cf220483e1fb1f530 Mon Sep 17 00:00:00 2001 From: "Aaron N. Brock" Date: Fri, 15 Nov 2019 14:11:50 -0500 Subject: Add support for chroma --- plugins/colorize/colorize.plugin.zsh | 47 +++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'plugins/colorize') diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index 565ba5a36..051d2269c 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -3,21 +3,46 @@ alias ccat='colorize_via_pygmentize' alias cless='colorize_via_pygmentize_less' colorize_via_pygmentize() { - if ! (( $+commands[pygmentize] )); then - echo "package 'Pygments' is not installed!" + + if [[ $ZSH_COLORIZE_TOOL != "chroma" && $ZSH_COLORIZE_TOOL != "pygmentize" ]]; then + echo "ZSH_COLORIZE_TOOL not recognized. Options are 'pygmentize' or 'chroma'" return 1 fi - # If the environment varianle ZSH_COLORIZE_STYLE + if [ -z $ZSH_COLORIZE_TOOL ]; then + if (( $+commands[pygmentize] )); then + ZSH_COLORIZE_TOOL="pygmentize" + elif (( $+commands[chroma] )); then + ZSH_COLORIZE_TOOL="chroma" + else + echo "niether 'Pygments' nor 'chroma' is not installed!" + return 1 + fi + fi + + echo "Tool: $ZSH_COLORIZE_TOOL" + + # If the environment variable ZSH_COLORIZE_STYLE # is set, use that theme instead. Otherwise, # use the default. if [ -z $ZSH_COLORIZE_STYLE ]; then - ZSH_COLORIZE_STYLE="default" + if [[ $ZSH_COLORIZE_TOOL == "pygmentize" ]]; then + ZSH_COLORIZE_STYLE="default" + else + # Choosing 'emacs' to match pygmentize's default as per: + # https://github.com/pygments/pygments/blob/master/pygments/styles/default.py#L19 + ZSH_COLORIZE_STYLE="emacs" + fi fi + echo "color style: $ZSH_COLORIZE_STYLE" # pygmentize stdin if no arguments passed if [ $# -eq 0 ]; then - pygmentize -O style="$ZSH_COLORIZE_STYLE" -g + if [[ $ZSH_COLORIZE_TOOL == "pygmentize" ]]; then + pygmentize -O style="$ZSH_COLORIZE_STYLE" -g + else + chroma --style="$ZSH_COLORIZE_STYLE" + fi return $? fi @@ -27,11 +52,15 @@ colorize_via_pygmentize() { local FNAME lexer for FNAME in "$@" do - lexer=$(pygmentize -N "$FNAME") - if [[ $lexer != text ]]; then - pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME" + if [[ $ZSH_COLORIZE_TOOL == "pygmentize" ]]; then + lexer=$(pygmentize -N "$FNAME") + if [[ $lexer != text ]]; then + pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME" + else + pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME" + fi else - pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME" + chroma --style="$ZSH_COLORIZE_STYLE" "$FNAME" fi done } -- cgit v1.2.3-70-g09d2 From 8aa070db0e1f8a5752f0e45834b7093b9b72860f Mon Sep 17 00:00:00 2001 From: "Aaron N. Brock" Date: Fri, 15 Nov 2019 15:34:24 -0500 Subject: Update README.md --- plugins/colorize/README.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'plugins/colorize') diff --git a/plugins/colorize/README.md b/plugins/colorize/README.md index d1f878e62..b6e27fd27 100644 --- a/plugins/colorize/README.md +++ b/plugins/colorize/README.md @@ -10,12 +10,23 @@ To use it, add colorize to the plugins array of your zshrc file: ``` plugins=(... colorize) ``` +## Configuration -## Styles +### Colorize tool + +Colorize supports using either the `pygmentize` tool or the `chroma` tool. By default colorize uses `pygmentize` unless it's not installed & `chroma` is installed. However, you can override this with the `ZSH_COLORIZE_TOOL` environment variable: + +``` +ZSH_COLORIZE_TOOL=chroma +``` + +### Styles Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable: -`ZSH_COLORIZE_STYLE="colorful"` +``` +ZSH_COLORIZE_STYLE="colorful" +``` ## Usage @@ -32,4 +43,6 @@ In the latter form, the file contents will be concatenated and presented by less ## Requirements -You have to install Pygments first: [pygments.org](http://pygments.org/download/) +You have to either install Pygments: [pygments.org](http://pygments.org/download/) + +Or install chroma: [https://github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) \ No newline at end of file -- cgit v1.2.3-70-g09d2 From d08238fb0f5150bfd0be8201537a2a8ca6dbbdc9 Mon Sep 17 00:00:00 2001 From: Jakob Probst Date: Sat, 16 Nov 2019 13:10:02 +0100 Subject: Fix some comments and messages. Remove (probably) debug messages. Improve ZSH_COLORIZE_TOOL recognition. --- plugins/colorize/README.md | 4 ++-- plugins/colorize/colorize.plugin.zsh | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'plugins/colorize') diff --git a/plugins/colorize/README.md b/plugins/colorize/README.md index b6e27fd27..38d17dc76 100644 --- a/plugins/colorize/README.md +++ b/plugins/colorize/README.md @@ -14,7 +14,7 @@ plugins=(... colorize) ### Colorize tool -Colorize supports using either the `pygmentize` tool or the `chroma` tool. By default colorize uses `pygmentize` unless it's not installed & `chroma` is installed. However, you can override this with the `ZSH_COLORIZE_TOOL` environment variable: +Colorize supports `pygmentize` and `chroma` as syntax highlighter. By default colorize uses `pygmentize` unless it's not installed and `chroma` is. This can be overridden by the `ZSH_COLORIZE_TOOL` environment variable: ``` ZSH_COLORIZE_TOOL=chroma @@ -30,7 +30,7 @@ ZSH_COLORIZE_STYLE="colorful" ## Usage -* `ccat [files]`: colorize the contents of the file (or files, if more than one are provided). +* `ccat [files]`: colorize the contents of the file (or files, if more than one are provided). If no arguments are passed it will colorize the standard input or stdin. * `cless [files]`: colorize the contents of the file (or files, if more than one are provided) and diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index 051d2269c..ac826e44b 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -3,11 +3,7 @@ alias ccat='colorize_via_pygmentize' alias cless='colorize_via_pygmentize_less' colorize_via_pygmentize() { - - if [[ $ZSH_COLORIZE_TOOL != "chroma" && $ZSH_COLORIZE_TOOL != "pygmentize" ]]; then - echo "ZSH_COLORIZE_TOOL not recognized. Options are 'pygmentize' or 'chroma'" - return 1 - fi + local available_tools=("chroma" "pygmentize") if [ -z $ZSH_COLORIZE_TOOL ]; then if (( $+commands[pygmentize] )); then @@ -15,12 +11,18 @@ colorize_via_pygmentize() { elif (( $+commands[chroma] )); then ZSH_COLORIZE_TOOL="chroma" else - echo "niether 'Pygments' nor 'chroma' is not installed!" + echo "Neither 'pygments' nor 'chroma' is installed!" return 1 fi fi - echo "Tool: $ZSH_COLORIZE_TOOL" + if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then + echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." + return 1 + elif (( $+commands[$ZSH_COLORIZE_TOOL] )); then + echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" + return 1 + fi # If the environment variable ZSH_COLORIZE_STYLE # is set, use that theme instead. Otherwise, @@ -35,7 +37,6 @@ colorize_via_pygmentize() { fi fi - echo "color style: $ZSH_COLORIZE_STYLE" # pygmentize stdin if no arguments passed if [ $# -eq 0 ]; then if [[ $ZSH_COLORIZE_TOOL == "pygmentize" ]]; then -- cgit v1.2.3-70-g09d2 From b776f1d20f0537cefec9b58e41933dfd04334b62 Mon Sep 17 00:00:00 2001 From: "Aaron N. Brock" Date: Sun, 17 Nov 2019 14:03:14 -0500 Subject: Fix issue recognizing if tools are insalled --- plugins/colorize/colorize.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/colorize') diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index ac826e44b..2335113d5 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -19,7 +19,7 @@ colorize_via_pygmentize() { if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." return 1 - elif (( $+commands[$ZSH_COLORIZE_TOOL] )); then + elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" return 1 fi -- cgit v1.2.3-70-g09d2 From c194b51560039707dc375412e70b6faa0d3ceaa5 Mon Sep 17 00:00:00 2001 From: "Aaron N. Brock" Date: Sun, 17 Nov 2019 14:10:03 -0500 Subject: Update default color to 'emacs' which both chroma & pygmentize support --- plugins/colorize/colorize.plugin.zsh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'plugins/colorize') diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index 2335113d5..8edf81d54 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -28,13 +28,8 @@ colorize_via_pygmentize() { # is set, use that theme instead. Otherwise, # use the default. if [ -z $ZSH_COLORIZE_STYLE ]; then - if [[ $ZSH_COLORIZE_TOOL == "pygmentize" ]]; then - ZSH_COLORIZE_STYLE="default" - else - # Choosing 'emacs' to match pygmentize's default as per: - # https://github.com/pygments/pygments/blob/master/pygments/styles/default.py#L19 - ZSH_COLORIZE_STYLE="emacs" - fi + # Both pygmentize & chroma support 'emacs' + ZSH_COLORIZE_STYLE="emacs" fi # pygmentize stdin if no arguments passed -- cgit v1.2.3-70-g09d2 From 5d5d202794ad62c51435798fdd464245f928e5db Mon Sep 17 00:00:00 2001 From: Jakob Probst Date: Sun, 17 Nov 2019 21:40:42 +0100 Subject: Echo to Error-Stream. Double quote to prevent globbing and word splitting. --- plugins/colorize/colorize.plugin.zsh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins/colorize') diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index 8edf81d54..e250397be 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -5,36 +5,36 @@ alias cless='colorize_via_pygmentize_less' colorize_via_pygmentize() { local available_tools=("chroma" "pygmentize") - if [ -z $ZSH_COLORIZE_TOOL ]; then + if [ -z "$ZSH_COLORIZE_TOOL" ]; then if (( $+commands[pygmentize] )); then ZSH_COLORIZE_TOOL="pygmentize" elif (( $+commands[chroma] )); then ZSH_COLORIZE_TOOL="chroma" else - echo "Neither 'pygments' nor 'chroma' is installed!" + echo "Neither 'pygments' nor 'chroma' is installed!" >&2 return 1 fi fi if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then - echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." + echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2 return 1 elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then - echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" + echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2 return 1 fi # If the environment variable ZSH_COLORIZE_STYLE # is set, use that theme instead. Otherwise, # use the default. - if [ -z $ZSH_COLORIZE_STYLE ]; then + if [ -z "$ZSH_COLORIZE_STYLE" ]; then # Both pygmentize & chroma support 'emacs' ZSH_COLORIZE_STYLE="emacs" fi # pygmentize stdin if no arguments passed if [ $# -eq 0 ]; then - if [[ $ZSH_COLORIZE_TOOL == "pygmentize" ]]; then + if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then pygmentize -O style="$ZSH_COLORIZE_STYLE" -g else chroma --style="$ZSH_COLORIZE_STYLE" @@ -48,7 +48,7 @@ colorize_via_pygmentize() { local FNAME lexer for FNAME in "$@" do - if [[ $ZSH_COLORIZE_TOOL == "pygmentize" ]]; then + if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then lexer=$(pygmentize -N "$FNAME") if [[ $lexer != text ]]; then pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME" -- cgit v1.2.3-70-g09d2 From 16ef5cca44d23fbde33de77cf44d0f05804d43e9 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Fri, 20 Dec 2019 21:45:39 -0800 Subject: Update link for Pygments Also moving the dependencies section up --- plugins/colorize/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'plugins/colorize') diff --git a/plugins/colorize/README.md b/plugins/colorize/README.md index 32dc97b6e..036724a1a 100644 --- a/plugins/colorize/README.md +++ b/plugins/colorize/README.md @@ -6,11 +6,17 @@ Colorize will highlight the content based on the filename extension. If it can't method for a given extension, it will try to find one by looking at the file contents. If no highlight method is found it will just cat the file normally, without syntax highlighting. +## Setup + To use it, add colorize to the plugins array of your zshrc file: ``` plugins=(... colorize) ``` +### Requirements + +This plugin requires that Pygments be installed: [pygments.org](https://pygments.org/) + ## Styles Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable: @@ -29,7 +35,3 @@ Note that `cless` will behave as less when provided more than one file: you have the commands `:n` for next and `:p` for previous. The downside is that less options are not supported. But you can circumvent this by either using the LESS environment variable, or by running `ccat file1 file2|less --opts`. In the latter form, the file contents will be concatenated and presented by less as a single file. - -## Requirements - -You have to install Pygments first: [pygments.org](http://pygments.org/download.html) -- cgit v1.2.3-70-g09d2 From e21fbe7dffff1619c2deb02eea8cccbd7e9814f4 Mon Sep 17 00:00:00 2001 From: ProbstDJakob Date: Sun, 22 Dec 2019 21:21:14 +0100 Subject: colorize: update plugin to support less options (#8392) --- plugins/colorize/README.md | 18 +++----- plugins/colorize/colorize.plugin.zsh | 83 +++++++++++++++++++++++++----------- 2 files changed, 64 insertions(+), 37 deletions(-) (limited to 'plugins/colorize') diff --git a/plugins/colorize/README.md b/plugins/colorize/README.md index d37443011..ee4ab8036 100644 --- a/plugins/colorize/README.md +++ b/plugins/colorize/README.md @@ -17,10 +17,10 @@ plugins=(... colorize) ### Requirements -This plugin requires that either of the following tools be installed: +This plugin requires that at least one of the following tools is installed: -* Chroma: [https://github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) -* Pygments be installed: [pygments.org](https://pygments.org/) +* [Chroma](https://github.com/alecthomas/chroma) +* [Pygments](https://pygments.org/download/) ### Colorize tool @@ -41,12 +41,8 @@ ZSH_COLORIZE_STYLE="colorful" ## Usage * `ccat [files]`: colorize the contents of the file (or files, if more than one are provided). - If no arguments are passed it will colorize the standard input or stdin. + If no files are passed it will colorize the standard input. -* `cless [files]`: colorize the contents of the file (or files, if more than one are provided) and - open less. If no arguments are passed it will colorize the standard input or stdin. - -Note that `cless` will behave as less when provided more than one file: you have to navigate files with -the commands `:n` for next and `:p` for previous. The downside is that less options are not supported. -But you can circumvent this by either using the LESS environment variable, or by running `ccat file1 file2|less --opts`. -In the latter form, the file contents will be concatenated and presented by less as a single file. +* `cless [less-options] [files]`: colorize the contents of the file (or files, if more than one are provided) and open less. + If no files are passed it will colorize the standard input. + The LESSOPEN and LESSCLOSE will be overwritten for this to work, but only in a local scope. diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index 3e91a9f46..6ed9739fa 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -1,8 +1,11 @@ -# easier alias to use the plugin -alias ccat='colorize_via_pygmentize' -alias cless='colorize_via_pygmentize_less' +# Easier alias to use the plugin +alias ccat="colorize_cat" +alias cless="colorize_less" -colorize_via_pygmentize() { +# '$0:A' gets the absolute path of this file +ZSH_COLORIZE_PLUGIN_PATH=$0:A + +colorize_check_requirements() { local available_tools=("chroma" "pygmentize") if [ -z "$ZSH_COLORIZE_TOOL" ]; then @@ -23,6 +26,12 @@ colorize_via_pygmentize() { echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2 return 1 fi +} + +colorize_cat() { + if ! colorize_check_requirements; then + return 1 + fi # If the environment variable ZSH_COLORIZE_STYLE # is set, use that theme instead. Otherwise, @@ -32,7 +41,7 @@ colorize_via_pygmentize() { ZSH_COLORIZE_STYLE="emacs" fi - # pygmentize stdin if no arguments passed + # Use stdin if no arguments have been passed. if [ $# -eq 0 ]; then if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then pygmentize -O style="$ZSH_COLORIZE_STYLE" -g @@ -42,12 +51,9 @@ colorize_via_pygmentize() { return $? fi - # guess lexer from file extension, or - # guess it from file contents if unsuccessful - + # Guess lexer from file extension, or guess it from file contents if unsuccessful. local FNAME lexer - for FNAME in "$@" - do + for FNAME in "$@"; do if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then lexer=$(pygmentize -N "$FNAME") if [[ $lexer != text ]]; then @@ -61,22 +67,47 @@ colorize_via_pygmentize() { done } -colorize_via_pygmentize_less() ( - # this function is a subshell so tmp_files can be shared to cleanup function - declare -a tmp_files +# The less option 'F - Forward forever; like "tail -f".' will not work in this implementation +# caused by the lack of the ability to follow the file within pygmentize. +colorize_less() { + if ! colorize_check_requirements; then + return 1 + fi - cleanup () { - [[ ${#tmp_files} -gt 0 ]] && rm -f "${tmp_files[@]}" - exit - } - trap 'cleanup' EXIT HUP TERM INT + _cless() { + # LESS="-R $LESS" enables raw ANSI colors, while maintain already set options. + local LESS="-R $LESS" - while (( $# != 0 )); do #TODO: filter out less opts - tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")" - tmp_files+=("$tmp_file") - colorize_via_pygmentize "$1" > "$tmp_file" - shift 1 - done + # This variable tells less to pipe every file through the specified command + # (see the man page of less INPUT PREPROCESSOR). + # 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like + # the ~/.zsh_history. For such files the tty of the preprocessor will be supended. + # Therefore we must source this file to make colorize_cat available in the + # preprocessor without the interactive mode. + # `2>/dev/null` will suppress the error for large files 'broken pipe' of the python + # script pygmentize, which will show up if less has not fully "loaded the file" + # (e.g. when not scrolled to the bottom) while already the next file will be displayed. + local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \ + ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \ + colorize_cat %s 2> /dev/null'" - less -f "${tmp_files[@]}" -) + # LESSCLOSE will be set to prevent any errors by executing a user script + # which assumes that his LESSOPEN has been executed. + local LESSCLOSE="" + + LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" less "$@" + } + + if [ -t 0 ]; then + _cless "$@" + else + # The input is not associated with a terminal, therefore colorize_cat will + # colorize this input and pass it to less. + # Less has now to decide what to use. If any files have been provided, less + # will ignore the input by default, otherwise the colorized input will be used. + # If files have been supplied and the input has been redirected, this will + # lead to unnecessary overhead, but retains the ability to use the less options + # without checking for them inside this script. + colorize_cat | _cless "$@" + fi +} -- cgit v1.2.3-70-g09d2