diff options
author | Andrew Gallant <jamslam@gmail.com> | 2016-11-20 11:14:52 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2016-11-20 11:14:52 -0500 |
commit | e8a30cb8934106e63f9d0938c547e535acb7b888 (patch) | |
tree | f1f7bb102ddcfc858c9ff65d04c34ec46810986d /doc | |
parent | 03f76053228b646a7febed3853ab28f42b83b1ad (diff) |
Completely re-work colored output and tty handling.
This commit completely guts all of the color handling code and replaces
most of it with two new crates: wincolor and termcolor. wincolor
provides a simple API to coloring using the Windows console and
termcolor provides a platform independent coloring API tuned for
multithreaded command line programs. This required a lot more
flexibility than what the `term` crate provided, so it was dropped.
We instead switch to writing ANSI escape sequences directly and ignore
the TERMINFO database.
In addition to fixing several bugs, this commit also permits end users
to customize colors to a certain extent. For example, this command will
set the match color to magenta and the line number background to yellow:
rg --colors 'match:fg:magenta' --colors 'line:bg:yellow' foo
For tty handling, we've adopted a hack from `git` to do tty detection in
MSYS/mintty terminals. As a result, ripgrep should get both color
detection and piping correct on Windows regardless of which terminal you
use.
Finally, switch to line buffering. Performance doesn't seem to be
impacted and it's an otherwise more user friendly option.
Fixes #37, Fixes #51, Fixes #94, Fixes #117, Fixes #182, Fixes #231
Diffstat (limited to 'doc')
-rw-r--r-- | doc/rg.1 | 22 | ||||
-rw-r--r-- | doc/rg.1.md | 16 |
2 files changed, 38 insertions, 0 deletions
@@ -143,6 +143,28 @@ Show NUM lines before and after each match. .RS .RE .TP +.B \-\-colors \f[I]SPEC\f[] ... +This flag specifies color settings for use in the output. +This flag may be provided multiple times. +Settings are applied iteratively. +Colors are limited to one of eight choices: red, blue, green, cyan, +magenta, yellow, white and black. +Styles are limited to either nobold or bold. +.RS +.PP +The format of the flag is {type}:{attribute}:{value}. +{type} should be one of path, line or match. +{attribute} can be fg, bg or style. +Value is either a color (for fg and bg) or a text style. +A special format, {type}:none, will clear all color settings for {type}. +.PP +For example, the following command will change the match color to +magenta and the background color for line numbers to yellow: +.PP +rg \-\-colors \[aq]match:fg:magenta\[aq] \-\-colors +\[aq]line:bg:yellow\[aq] foo. +.RE +.TP .B \-\-column Show column numbers (1 based) in output. This only shows the column numbers for the first match on each line. diff --git a/doc/rg.1.md b/doc/rg.1.md index 8e6226d7..11487d69 100644 --- a/doc/rg.1.md +++ b/doc/rg.1.md @@ -95,6 +95,22 @@ Project home page: https://github.com/BurntSushi/ripgrep -C, --context *NUM* : Show NUM lines before and after each match. +--colors *SPEC* ... +: This flag specifies color settings for use in the output. This flag may be + provided multiple times. Settings are applied iteratively. Colors are limited + to one of eight choices: red, blue, green, cyan, magenta, yellow, white and + black. Styles are limited to either nobold or bold. + + The format of the flag is {type}:{attribute}:{value}. {type} should be one + of path, line or match. {attribute} can be fg, bg or style. Value is either + a color (for fg and bg) or a text style. A special format, {type}:none, + will clear all color settings for {type}. + + For example, the following command will change the match color to magenta + and the background color for line numbers to yellow: + + rg --colors 'match:fg:magenta' --colors 'line:bg:yellow' foo. + --column : Show column numbers (1 based) in output. This only shows the column numbers for the first match on each line. Note that this doesn't try |