使用 tput 的 AIX putty 终端颜色

AIX putty terminal color using tput

我正在尝试使用 tput setb 或 setab 函数设置颜色,但我无法获得颜色。在积极的一面 tput bold ,下划线之类的功能正在运行。我找不到 setb 功能问题的任何原因。

print $(tput bold)"Text is bold"$(tput sgr0)

能否请您帮我使用 tput set 函数创建颜色?

我使用的是 putty 0.65 版本,TERM=xterm-256color 和 AIX 版本 = 7.1

我尝试使用不同于 google 的方法,如下所示。 但我想使用 tput set 来实现简单的目的,而不是硬编码颜色值。 请帮助我理解。

__GREEN='3[0;32m'
print  ${__GREEN}$(tput bold)"Green color Bold" $(tput sgr0)

终端描述中未提供 setb(和 setf)功能,因为它们'重新用于 non-ANSI 颜色。使用 setab(和 setaf)。

  • To change the current foreground or background color on a Tektronix-type terminal, use setaf (set ANSI foreground) and setab (set ANSI background) or setf (set foreground) and setb (set background). These take one parameter, the color number. The SVr4 documentation describes only setaf/setab; the XPG4 draft says that "If the terminal supports ANSI escape sequences to set background and foreground, they should be coded as setaf and setab, respectively.

ncurses' terminfo manpage 是这样说的:

  • If the terminal supports other escape sequences to set background and foreground, they should be coded as setf and setb, respectively. The vidputs and the refresh(3x) functions use the setaf and setab capabilities if they are defined.

颜色以任意方式编号:

for n in 0 1 2 3 4 5 6 7;do tput setab $n;echo background $n;done; tput sgr0

我在下面进行了定义并且有效。谢谢!

 __GREEN='3[0;32m'
 __NC='3[0m' # No Color

 print -n ${__GREEN}$(tput bold)
 banner  DEVELOPER
 print -n $(tput sgr0)${__NC}

我正在使用 AIX Lpar 和 putty