当用户在linux/unix中使用write user [ttyname]命令发送我的终端文本时,有没有一种方法可以trap或捕获自动写入我终端的文本,并改变它的颜色,使其更明显?
来自man write
Write allows you to communicate with other users, by copying lines from your terminal to theirs.
我添加了一个别名,所以当我使用write时,我的文本会改变颜色,即:
alias write='echo -e "\033[1;31m\c" ; write '
但这只
我试图改变某一行文字的颜色。我看过其他文章(包括),但没有看任何工作。如果可能的话,我不想安装任何外部模块。
我的代码:
from subprocess import call
call('color a', shell=True) #this sets the color to light green
print('The quick brown fox jumps over the lazy dog.')
我在Linux上使用Python3.2.3。谢谢你的回复。