Color support for non-xterm terminals
philer opened this issue · 6 comments
The nocolor check is a bit too strict:
NOCOLOR = not os.isatty(2) or os.name == 'nt' or os.getenv('TERM', '')[:5] != 'xterm'
There are a lot of terminals that don't set their TERM env to xterm but support colors (e.g. TERM=urxvt-unicode-256color), including the TTYs on many systems. I'd suggest omitting the TERM check or limiting it to a few common excludes.
PS: If anyone else uses a terminal where color support is blocked (like urxvt) you can work around it by explicitly overwriting the NOCOLOR variable:
import better_exceptions
better_exceptions.NOCOLOR = False
Yep, I'll do a proper fix for this sometime today.
Does the branch fix-colors
work for you? :)
@philer could you test the latest on fix-colors
?
If you're not getting any colors, make sure curses
/ncurses
is installed. This isn't required on Windows as it falls back to Colorama.
There seems to be a bug with Colorama on Windows under Python 3. Can track the progression of that bug in tartley/colorama#125. Python 2 is confirmed to work.
Mac:
$ brew install homebrew/dupes/ncurses
Ubuntu:
$ sudo apt-get install libncurses5-dev
I tested personally in Windows. Other than the above bug, this is working for all terminals (not just xterm).
Any problems with the new detection method should go into a new ticket :)
Released as 0.1.4
.