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

Added support for basic colors #7

Closed
wants to merge 3 commits into from
Closed

Conversation

donebizkit
Copy link

You can use basic colors as follows:
hr . red
hr ++ yellow
hr blue

Added support for base colors. e.g.
hr . red
hr +- yellow
hr cyan
How to use colors
@LuRsT
Copy link
Owner

LuRsT commented Feb 10, 2014

Hi!

Thank you very much for the pull request!

This is a very good idea, I wonder if we could not have the hard-coded colours in the script thought, it doesn't look good...

Another thing that I dislike is that if you misspell a colour, you get the character in the separator.

Cheers

@donebizkit
Copy link
Author

How about this ...
I changed it to support named arguments so that it's clearer. [-p] for pattern and [-c] for colors
e.g.
hr -p == -c red

It also allows to enter a number from 0 to 256 for custom colors
e.g.
hr -c 124

I also kept the hardcoded shortcuts because not everyone knows color codes.
e.g.
hr -c blue

If you enter an out of range number or a mispelled color name, it doesn't affect the output.

@cbanu
Copy link

cbanu commented Feb 12, 2014

How about using some other command through which you can pipe the output from 'hr'? Not sure if this doesn't already exist. You could name it 'hl' to keep it simple (highlight). Then you could write something like:
hr '=' | hl red

Of course, you can add extra features to it, like support for HTML color codes, foreground / background colors, blinking (if you really want to annoy your users), etc.

And you could also combine it to have one row in one color, followed by another in a different color:

hr '=' | hl white && hr '#' | hl gray

Edit: Sorry if I 'hijacked' the thread, didn't mean to.

@LuRsT
Copy link
Owner

LuRsT commented Feb 13, 2014

Hi @cbanu,

Thank you for your input, actually I was thinking about something like that, since then hr would not need to care about colours.

I have an idea in mind...hold on.

Cheers

@LuRsT
Copy link
Owner

LuRsT commented Feb 13, 2014

Hi guys,

This discussion gave me the idea of creating a span like script for bash, thank you again for your input and help.

@donebizkit I used a lot of your code in the new project, if you want, I can add an empty commit on your behalf just so you can appear in the contributors section of the project, if you want me to. So I will close this issue since colouring was added very very indirectly to hr.

I added you two to the acknowledgements section of the README of the repo of course :).

Here is the span: https://github.com/LuRsT/span

Cheers

@LuRsT LuRsT closed this Feb 13, 2014
@donebizkit
Copy link
Author

The acknowledgement is enough. I'll keep an eye of both projects in case I have something to add.

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.

3 participants