gpt4 book ai didi

linux - 如何窃取在 Linux shell 上运行的任何命令的输出?

转载 作者:太空宇宙 更新时间:2023-11-04 05:14:41 24 4
gpt4 key购买 nike

我正在使用 bash/zsh。我想窃取在 shell 终端上运行的任何命令的输出并将其着色,然后显示在终端上。

[user@machine]$ my-command-to-exe-tests --run-all-tcs
bunch of output
bunch of output
bunch of output
bunch of output
[user@machine]$

有没有办法在不使用管道|的情况下做到这一点。就像终端上显示的任何输出都必须经过我的程序一样。是否可以 Hook pts 或 tty 来窃取终端上运行的任何命令的输出流?

最佳答案

如果您可以接受随机着色,那么您可以使用 lolcat 工具来完成该任务。

$ lolcat <(your command) 

关于linux - 如何窃取在 Linux shell 上运行的任何命令的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50941194/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com