linux - 是否可以确定 linux 机器中终端的背景颜色?

标签 linux ubuntu system

我正在构建一个 node.js CLI,我想显示一个 ASCII 艺术标志。但是根据终端的背景颜色,我想更改 Logo 的颜色。是否有可能做到这一点?如果是如何?谢谢。

最佳答案

你要找的在这里:

这里:

#!/bin/sh
#
# Query a property from the terminal, e.g. background color.
#
# XTerm Operating System Commands
#     "ESC ] Ps;Pt ST"

oldstty=$(stty -g)

# What to query?
# 11: text background
Ps=${1:-11}

stty raw -echo min 0 time 0
# stty raw -echo min 0 time 1
printf "\033]$Ps;?\033\\"
# xterm needs the sleep (or "time 1", but that is 1/10th second).
sleep 0.00000001
read -r answer
# echo $answer | cat -A
result=${answer#*;}
stty $oldstty
# Remove escape at the end.
echo $result | sed 's/[^rgb:0-9a-f/]\+$//'

关于linux - 是否可以确定 linux 机器中终端的背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43931304/

相关文章:

ubuntu - Maven Ant SCP 错误

django apache2 ubuntu wsgi 错误无法导入 foobar.settings

c - 具有常量成员的结构的内存分配

c# - C# 中的 C++ "system()"

c++ - 如何使用 system() 在 c 中执行 2 个连续的系统命令,例如连接到 ftp 并使用程序登录?

php - 如何让 PHP、Symlinks 和 __FILE__ 很好地协同工作?

linux - Sox(瑞士军刀)使用什么算法来消除静音和噪音

ubuntu - 为 Raspberry Pi 交叉编译第三方库的非繁琐方法

php - 为什么mkdir模式参数以0开头?

java - 运行 Jitsi-meet [jicofo 组件] 时出现问题?