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

tig not showing git colors in pager mode #8

Closed
jmatraszek opened this issue Apr 3, 2011 · 9 comments
Closed

tig not showing git colors in pager mode #8

jmatraszek opened this issue Apr 3, 2011 · 9 comments

Comments

@jmatraszek
Copy link

Hi.
In my gitconfig I have:
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
whitespace = red reverse
[color "status"]
added = yellow
changed = green
untracked = cyan

but this breaks showing colors in tig (in pager mode). That's the example output from git diff:
^[[1;33mindex 8400b58..a9ce073 100644^[[m
^[[1;33m--- a/gitconfig^[[m
^[[1;33m+++ b/gitconfig^[[m
^[[1;35m@@ -18,19 +18,16 @@^[[m
frag = magenta bold^[[m
old = red bold^[[m
new = green bold^[[m
^[[1;32m+^[[m^[[1;32m whitespace = red reverse^[[m
[color "status"]^[[m
added = yellow^[[m
changed = green^[[m
untracked = cyan^[[m
^[[m
^[[1;31m-[color]^[[m
^[[1;31m- ui = true^[[m
^[[1;31m-[color "diff"]^[[m
^[[1;31m- whitespace = red reverse^[[m
[core]^[[m

@jonas
Copy link
Owner

jonas commented Apr 3, 2011

Tig is not using git's color settings in pager mode and it does not support reading the the ANSI color codes from stdin, which is probably why it looks broken. This is one reason why tig always passes the --no-color argument to git-diff(1) and git-log(1).

@lkraav
Copy link

lkraav commented Aug 5, 2011

ok so is .bashrc (1):

git() { if [ $1 = "diff" -o $1 = "show" ]; then CMD=$1; shift; command git $CMD --no-color "$@"; else command git "$@"; fi; }

so far our only solution?

@lkraav
Copy link

lkraav commented Aug 9, 2011

EDIT: updated workaround to also handle file name parameters given after "git diff".

@jonas
Copy link
Owner

jonas commented Aug 11, 2011

There's a git config setting that allow you to enable colors only when git output is written to a tty/terminal.

@lkraav
Copy link

lkraav commented Aug 11, 2011

   color.diff
       Whether to use ANSI escape sequences to add color to patches. If this is set to always, git-diff(1), git-log(1), and git-show(1) will use color for all patches. If it is set to true or auto, those
       commands will only use color when output is to the terminal. Defaults to false.

That's great. Except setting it to true or auto in my case didn't make a single bit of difference, tig still received ANSI sequences.

@lkraav
Copy link

lkraav commented Aug 17, 2011

EDIT: also include colorless "git show" in the function. haven't had time to debug why exactly piping doesn't cause colors to be auto-dropped.

jonas added a commit that referenced this issue Apr 10, 2012
@jonas
Copy link
Owner

jonas commented Apr 10, 2012

I've added support for loading git's color setting. With respect to the other issue, I think it is better resolved on [email protected]

@jonas jonas closed this as completed Apr 10, 2012
@jhoffmann
Copy link

I recently had a similar issue when I set core.pager to tig, which was resolved by setting color.pager to no.

@ghost
Copy link

ghost commented Feb 17, 2014

@jhoffmann - This resolution worked perfectly for me. Thanks.

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

4 participants