mfontanini / presenterm

A markdown terminal slideshow tool
https://mfontanini.github.io/presenterm/
BSD 2-Clause "Simplified" License
1.19k stars 29 forks source link

feat: globally enable colored terminal output? #315

Closed calebdw closed 1 month ago

calebdw commented 1 month ago

Hello!

Would it be possible to add a config option (or just set it globally) to enable terminal colors in the output from programs? It would be nice to globally enable so that I don't have to specifically configure every command to output color:

e.g.,

```bash +exec
ls -alh
```
<!-- instead of -->
```bash +exec
ls -alh --color=always
```

Thanks!

mfontanini commented 1 month ago

I imagine tools will look up some specific environment variable like TERM to figure out color support. However, I think before doing this, color support should work better (see #272 and there's an open PR that needs some work still). I was meaning to get to that but I was busy and prioritized the 0.8 release over this. I'll bump it up in my priority list.

mfontanini commented 1 month ago

Okay so looking at this it may not be that simple. Tools seem to check if they're running in a tty before enabling color when you use "auto" color mode (e.g. ls, grep, etc). The TERM thing I mentioned above would not work because that is always set so that'd mean if you do files=$(ls) then you'd have colored output in $files and that's not desireable.

I don't know if there's another solution but using a tty will be a huge amount of work as it will cause tools to use a wider range of escape codes that we'll need to deal with, like moving the cursor around, so I don't want to go that route.

calebdw commented 1 month ago

Ah, well that's good to know!

henryiii commented 1 month ago

Lots of tools use FORCE_COLOR, so if there was a way to set environment variables, that would likely mostly solve it.