cheat
cheat copied to clipboard
Don't use escape sequences when redirecting output
cheat show git > output.txt or cheat show git | xclip
These commands pretty-print the output so escape sequences are printed too. Which just messes up the output. This is how it looks:
[33;5m# To set your identity:[0m
[36;5m(1)[0m git config --global user.name "John Doe"
[36;5m(2)[0m git config --global user.email [email protected]
[33;5m# To set your editor:[0m
[36;5m(3)[0m git config --global core.editor emacs
[33;5m# To enable color:[0m
[36;5m(4)[0m git config --global color.ui true
Is there a way to automatically disable escape codes, when redirecting output, or should we take a command line option like --plain?
you can use https://github.com/mattn/go-isatty
@mattn isatty worked, but i think having a switch for colored/plain output won't be wrong because there might be some cases where we are piping the output but still want colors, like cheat show git | less (having colors in less would be okay)
how about -color=[always|never|auto] like ls command?
Yeah, that sounds good.