ad-si / TaskLite

The CLI task manager for power users
https://tasklite.org
GNU Affero General Public License v3.0
216 stars 12 forks source link

Piping output of tasklite to file still includes colors #44

Open jnduli opened 3 years ago

jnduli commented 3 years ago

I'm not quite sure if this is a bug or something that needs to be fixed, but I recently piped output of tasklite to a file with tasklite >> file

The file still contains the color symbols though:

Id   Prio  Opened UTC  Body        
gq7   0    2020-11-20  test 2
15h   0    2020-11-20  test 1

I was able to fix this with a sed command I got, so if this is intended behaviour we can just close the issue (I'm also not sure how this can be fixed from the haskell side :cry: )

ad-si commented 3 years ago

Yeah, this is already on my own todo list. The last time I checked there was no easy way to figure out wether you print to the terminal or pipe the output to another file. I know however, that it's possible in JavaScript. So implementing this with a flag would be an unsatisfying solution. 😅

I think I need to investigate a little further, but If anyone knows a way to achieve this, a tip would be highly appreciated 🙃.

jnduli commented 3 years ago

Noted. I'll try to do some research on my side and comment if I find something plausible

jnduli commented 3 years ago

Here's what I've found so far:

So a possible alternative would be to have a config that is set at run time depending on whether the output is tty or not.

Also adding a terminal option that will force colors if set. For example, if I do ls --color >> file the file has the colors.