gpt4 book ai didi

linux - 使用 sed 为选项卡添加背景颜色?

转载 作者:IT王子 更新时间:2023-10-29 00:43:01 25 4
gpt4 key购买 nike

是否可以使用 sed 更改选项卡(或任何其他文本)的背景颜色,以便,例如,我可以运行如下所示的内容?

somefunction | sed -e 's/(some pattern)/(set bg color)\1(unset bg color)/g'

最佳答案

是的:

#!/bin/bash

norm_bg=$(tput sgr0)
red_bg=$(tput setab 1)

echo -e "foo\tbar\tbaz" | sed "s/\t/$red_bg $norm_bg/g"

请参阅此链接了解其他 Color Codes (很底)

terminal

关于linux - 使用 sed 为选项卡添加背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5575109/

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