Commit d08238fb authored by Jakob Probst's avatar Jakob Probst
Browse files

Fix some comments and messages. Remove (probably) debug messages. Improve...

Fix some comments and messages. Remove (probably) debug messages. Improve ZSH_COLORIZE_TOOL recognition.
parent 8aa070db
...@@ -14,7 +14,7 @@ plugins=(... colorize) ...@@ -14,7 +14,7 @@ plugins=(... colorize)
### Colorize tool ### 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 ZSH_COLORIZE_TOOL=chroma
...@@ -30,7 +30,7 @@ ZSH_COLORIZE_STYLE="colorful" ...@@ -30,7 +30,7 @@ ZSH_COLORIZE_STYLE="colorful"
## Usage ## Usage
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided). * `ccat <file> [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 arguments are passed it will colorize the standard input or stdin.
* `cless <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and * `cless <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and
......
...@@ -3,11 +3,7 @@ alias ccat='colorize_via_pygmentize' ...@@ -3,11 +3,7 @@ alias ccat='colorize_via_pygmentize'
alias cless='colorize_via_pygmentize_less' alias cless='colorize_via_pygmentize_less'
colorize_via_pygmentize() { colorize_via_pygmentize() {
local available_tools=("chroma" "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
if [ -z $ZSH_COLORIZE_TOOL ]; then if [ -z $ZSH_COLORIZE_TOOL ]; then
if (( $+commands[pygmentize] )); then if (( $+commands[pygmentize] )); then
...@@ -15,12 +11,18 @@ colorize_via_pygmentize() { ...@@ -15,12 +11,18 @@ colorize_via_pygmentize() {
elif (( $+commands[chroma] )); then elif (( $+commands[chroma] )); then
ZSH_COLORIZE_TOOL="chroma" ZSH_COLORIZE_TOOL="chroma"
else else
echo "niether 'Pygments' nor 'chroma' is not installed!" echo "Neither 'pygments' nor 'chroma' is installed!"
return 1 return 1
fi fi
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 # If the environment variable ZSH_COLORIZE_STYLE
# is set, use that theme instead. Otherwise, # is set, use that theme instead. Otherwise,
...@@ -35,7 +37,6 @@ colorize_via_pygmentize() { ...@@ -35,7 +37,6 @@ colorize_via_pygmentize() {
fi fi
fi fi
echo "color style: $ZSH_COLORIZE_STYLE"
# pygmentize stdin if no arguments passed # pygmentize stdin if no arguments passed
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
if [[ $ZSH_COLORIZE_TOOL == "pygmentize" ]]; then if [[ $ZSH_COLORIZE_TOOL == "pygmentize" ]]; then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment