Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Option in Tee to remove color #108

Open
JimF42 opened this issue Feb 15, 2023 · 2 comments
Open

Feature request: Option in Tee to remove color #108

JimF42 opened this issue Feb 15, 2023 · 2 comments

Comments

@JimF42
Copy link

JimF42 commented Feb 15, 2023

Please consider an option for Tee to strip off color escape sequences when writing to the output file.

For example, I ran du | tee <file>, and I had to manually edit out all of the color escape sequences after it was finished.

@malxau
Copy link
Owner

malxau commented Feb 22, 2023

Thanks for the report.

I'll probably end up doing the simple thing, but I'm asking in case you can see a "better" alternative. Outside of tee, this would normally be solved with pipes. Specifically, cvtvt -text can be used to strip VT escapes. Unfortunately that doesn't work for tee, which is writing to a file directly and has no way to insert pipes into that stream.

So, considering that this is open source, there's a single repo that implements piping and execution that also has tee. It seems like it ought to be possible for tee to support pipes on the file stream, and the challenge is inventing a syntax to let it do so that doesn't create more problems than it solves.

Would it make sense to be able to do something like:
df | tee -c "cvtvt -text" file
?

Another option would be to optionally invert tee's behavior. Currently tee writes to a file (without pipe support), and writes to stdout (which can be further piped.) An inverted tee would write to the display (without pipe support) and write to stdout (which can be further piped, ultimately to a file.)

Part of the reason I'm asking is because I think there are other operations that make sense to perform on the file as well (eg. iconv.)

Of course, there may be other options too. Do you see any more generic/elegant approach to this aside from hardcoding one specific operation into tee?

@JimF42
Copy link
Author

JimF42 commented Feb 23, 2023

While I think the idea of having the double pipe sounds cool, to be able to pipe to cvtvt first, I will have to leave that decision up to you because of effort needed.

I'm really new to using Yori, so I can't say right now how else I would use the new piping engine that would be required to do this for tee

As far as inverting tee, that bothers me a bit as tee in general is so well known, that it may be confusing to some, and no longer backwards compatible for existing users. If you did this, you would either need a new command to avoid confusion, or, a non-default set of switches that inverts the default behavior.

In some ways, I think your example of df | tee -c "cvtvt -text" file makes the best sense if you are not going to simply "hardcode" the cvtvt features into tee.

Otherwise, it would probably be something like df | tee -c[onsole] | cvtvt -text file, if you want to allow for an inverted tee (if that's even possible since they will both ultimately be going to the console).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants