has icon indicating copy to clipboard operation
has copied to clipboard

[feature] add support for detecting the stdout

Open Freed-Wu opened this issue 3 years ago • 0 comments

❯ has python > a.txt && cat -A a.txt
^[[1m^[[32mM-bM-^\M-^S^[[m^O python ^[[1m^[[33m3.9.6^[[m^O$

why not let has detect stdout? if the output is a stdout, let has output with color, if the output is a file, let has output without color. A simple solution is

# stdout is /dev/fd/1
[ -t 1 ] && color=1 || color=0

Moreover, like a option named --color={always, auto, never}, default is auto will be better. many program like fd, rg, exa use --color to control if the program output with color.

thanks.

Freed-Wu avatar Aug 09 '21 14:08 Freed-Wu