laike9m / pdir2

Pretty dir() printing with joy:beer:
MIT License
1.33k stars 47 forks source link

Support disable color and switch off color when stdout is not a TTY #67

Closed laixintao closed 2 years ago

laixintao commented 2 years ago

You can disable color output by setting colorful-output = False in ~/.pdir2config now.

Example:

[global]
colorful-output = True

True means always use color, False means always disable color, and auto means using color output when stdout is a TTY, otherwise not.

You can also disable colors by environment variable export PDIR2_NOCOLOR=1. The environment has higher priority than the config file.

close #65

laixintao commented 2 years ago

I added a fake color render COLOR_DISABLED to render plain text without escape code.

If it is ok for you, then I will complete this PR with more docs and test cases. @laike9m

laixintao commented 2 years ago

I don't have permission to edit doc in wiki so i put the doc in this description, you can copy it to wiki.

and I don't mind if you squash merge, the commit log is a bit messy due to fixing the ci. @laike9m

laike9m commented 2 years ago

Let me know if I need to review

laixintao commented 2 years ago

@laike9m I applied you suggestions already, please review again and leave some comments if there is anything more need to be improved.

laixintao commented 2 years ago

ready for review again, you can merge #68 first

laixintao commented 2 years ago

refactored some import pdir move them to top if necessary.

laike9m commented 2 years ago

LGTM, thanks again!