Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding color #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

adding color #4

wants to merge 2 commits into from

Conversation

Var7600
Copy link

@Var7600 Var7600 commented Jul 30, 2024

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.

Var7600 and others added 2 commits July 30, 2024 17:10
@wjandrea
Copy link
Owner

wjandrea commented Aug 7, 2024

Thanks, this is interesting, but I want to make colours optional so that what still works properly on terminals that don't support colour.

@@ -3,6 +3,10 @@
#
# See functions "_usage" and "_help" for more details.

## COLOR
GREEN="\033[0;32m"
NORMAL="\033[0;00m"
Copy link
Owner

@wjandrea wjandrea Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0;00 is redundant. Just use 0

## COLOR
GREEN="\033[0;32m"
NORMAL="\033[0;00m"
RED="\033[0;31m"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On source, these will be in the environment and could easily be overwritten. I would obfuscate them like the functions: _What_GREEN etc

@@ -38,7 +43,8 @@ function _What_alias { (
if [[ $print_definition == true ]]; then
# Print the *current* definition.
_What_indent 2
printf "definition: "
# shellcheck disable=SC2059
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to do this when you can use %b instead: printf "%bdefinition%b: " "$GREEN" "$NORMAL"

@@ -228,19 +236,20 @@ function _What_function { (
read -r _ attrs _ <<< "$(declare -pF -- "$function")"

# 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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove? Is this just a typo?

@Var7600
Copy link
Author

Var7600 commented Aug 11, 2024

Thanks, this is interesting, but I want to make colours optional so that what still works properly on terminals that don't support colour.

so can i add a option like --color to output with colors?

@wjandrea
Copy link
Owner

so can i add a option like --color to output with colors?

Yeah, that'd work. Although, what uses getopts, so it'd have to be a single character like -c.

(Sorry for the delay. I missed your reply somehow.)

@Var7600
Copy link
Author

Var7600 commented Aug 20, 2024

so can i add a option like --color to output with colors?

Yeah, that'd work. Although, what uses getopts, so it'd have to be a single character like -c.

(Sorry for the delay. I missed your reply somehow.)

okay -c option i'm going to try base on your suggestions and reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants