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

Make colors configurable #90

Closed
earwin opened this issue Oct 12, 2012 · 9 comments
Closed

Make colors configurable #90

earwin opened this issue Oct 12, 2012 · 9 comments

Comments

@earwin
Copy link

earwin commented Oct 12, 2012

No description provided.

@ggreer
Copy link
Owner

ggreer commented Oct 12, 2012

I have nothing against this feature, but would this be an environment variable or a command line parameter or config file or what?

@earwin
Copy link
Author

earwin commented Oct 13, 2012

No hard preferences here.
Maybe envars are a teeny little bit worse choice then the other two, as they pollute the shared namespace.
Command-line param seems the easiest way out, since you parse these already and have no configs as of yet?

@gurgeous
Copy link
Contributor

Just started playing with ag after reading about it on HN today. I'd like to customize the color too. Perhaps something simple like:

--colors-path "1;32"
--colors-match "30;43"
--colors-line-number "1;33"

An AG_OPTIONS environment variable (similar to GREP_OPTIONS) would be appreciated too, naturally. I might try to put together a pull request, if I can resuscitate my rusty C skills. :)

Another (minor) suggestion - perhaps you could update the PPA? I was getting ready to file some bugs related to .gitignore, but they seem to be fixed.

Thanks for creating this!

@ggreer
Copy link
Owner

ggreer commented Nov 29, 2012

I'm not a fan of AG_OPTIONS. Bash aliases solve the same problem, and they work with any program.

I've deleted my PPA. I'm done dealing with debian/rules, and it's better to have no PPA than an outdated one. If someone wants to maintain their own PPA, I'll link to it in the README.

I'll add support for color customization later today.

@gurgeous
Copy link
Contributor

Now I feel bad! Was maintaining the PPA a burden? I don't know what's involved, really.

As an aside, an environment variable can be advantageous vs. an alias if you end up running searches within tools like emacs. No biggie though. I use a ton of aliases too.

I made this change today to preview ag with spiffy new colors:

const char *colors_path = "\e[0;35m";
const char *colors_match = "\e[1;35m";
const char *colors_line_number = "\e[0;32m";

Can't wait to check out the new flags. Thanks!

@ggreer
Copy link
Owner

ggreer commented Nov 29, 2012

Good point about running from emacs. You've convinced me. Now I'm not against an AG_OPTIONS.

I tried writing the feature a while ago, but gave up. It looked simple initially, but I couldn't find a simple way to parse a string into a format read by getopt_long.

As long as the implementation isn't a crazy huge/complicated pull request, I'm fine with merging it. I doubt I'll ever write it myself.

@ggreer
Copy link
Owner

ggreer commented Nov 29, 2012

Ok take a look at master now. You can configure colors like this:

ag --color-path "1;32" --color-match "30;41" --color-line-number "2;33" blah

@gurgeous
Copy link
Contributor

This is great, works perfectly! Here's what I'm using for my solarized shell:

alias ag="ag --color-path 35 --color-match '1;35' --color-line-number 32"

I think the trick with getopt_long would be to parse the env variable into an array, then prepend to argc/argv. I'll try to take a crack at it if I get a chance. Maybe I can dust off valgrind too. I don't trust myself.

Thanks for making the change!

@ggreer
Copy link
Owner

ggreer commented Nov 29, 2012

Cool. I'll close this issue then.

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

No branches or pull requests

3 participants