adding color#4
Conversation
added images showing output with colors
|
Thanks, this is interesting, but I want to make colours optional so that |
|
|
||
| ## COLOR | ||
| GREEN="\033[0;32m" | ||
| NORMAL="\033[0;00m" |
| ## COLOR | ||
| GREEN="\033[0;32m" | ||
| NORMAL="\033[0;00m" | ||
| RED="\033[0;31m" |
There was a problem hiding this comment.
On source, these will be in the environment and could easily be overwritten. I would obfuscate them like the functions: _What_GREEN etc
| # Print the *current* definition. | ||
| _What_indent 2 | ||
| printf "definition: " | ||
| # shellcheck disable=SC2059 |
There was a problem hiding this comment.
No reason to do this when you can use %b instead: printf "%bdefinition%b: " "$GREEN" "$NORMAL"
|
|
||
| # Find the source by turning on extended debugging. | ||
| # Looping not required because only one definition exists at a time. | ||
| # Looping not required because only one exists at a time. |
There was a problem hiding this comment.
Why remove? Is this just a typo?
so can i add a option like |
Yeah, that'd work. Although, (Sorry for the delay. I missed your reply somehow.) |
okay |
|
Looks, like this got forgotten about. However, if you care about portable terminal colour codes then try using RED=1
GREEN=2
put_green() {
tput setaf $GREEN # sets foreground colour to green if terminal supports colors
echo $@
tput sgr0 # resets terminal to initial state
}Alternatively, if you want to avoid two RED="$( tput setaf 1 )"
GREEN="$( tput setaf 2 )"
RESET="$( tput sgr0 )"
put_color() {
printf "%s%s%s\n" "$1" "${*:2}" "$RESET"
}
put_color $GREEN foo barAlmost everyone has an xterm, so this basically reduces to the escape codes you already have in this PR. |
dded color RED for: keyword, builtin, alias/file, function, multiple
files/absolute symlinks, relative symlink
and color GREEN for the rest.
added output example with color for the README file.