tput用法详解-渐入佳境

tput用法详解-渐入佳境作者:飞翔的小胖猪 创建时间:2021年2月28日 tput 命令将通过 terminfo 数据库对终端会话进行初始化和操作。 主要功能为:移动更改光标、更改文本属性颜色、清除屏幕特定区域、 可以更改终端功能,如移动或更改光标、更改文本属性,以及清除终端屏幕的特定区域。在shell编程的时候

–作者:飞翔的小胖猪

–创建时间:2021年2月28日

tput 命令将通过 terminfo 数据库对终端会话进行初始化和操作。

主要功能为:移动更改光标、更改文本属性颜色、清除屏幕特定区域、

可以更改终端功能,如移动或更改光标、更改文本属性,以及清除终端屏幕的特定区域。在shell编程的时候可以用来设置颜色。

命令格式:

  tput [option] [parameter]

4.1 tput设置

4.1.1 文本属性颜色

格式:
  tput setab [0-7] – 设置背景色。
  tput setaf [0-7] – 设置前景色。
​参数:
  0 – Black,黑色
  1 – Red,红色
  2 – Green,绿色
  3 – Yellow,黄色
  4 – Blue,蓝色
  5 – Magenta,品红
  6 – Cyan,青色
  7 – White,白色

例子:

设置背景色为黄色。

[root@135 ~]# tput setab 3

tput用法详解-渐入佳境

设置前景色为黄色

[root@135 ~]# tput setaf 3

tput用法详解-渐入佳境

4.1.2 文本属性颜色

​格式:
  tput 参数   

参数: tput bold – Set bold mode,加粗字体。 tput dim – turn on half
-bright mode,打开高亮模式。 tput smul – begin underline mode,添加下划线。 tput rmul – exit underline mode,取消下划线。 tput rev – Turn on reverse mode,突出模式,所有输出字符都突出显示。 tput smso – Enter standout mode,突出模式,所有输出字符都突出显示。 tput rmso – Exit standout mode,退出突出显示。 tput sgr0 – Turn off all attributes,取消所有属性。

例子:

设置字符加粗

[root@135 ~]# tput bold

tput用法详解-渐入佳境

设置取消下划线

#设置显示下划线
[root@135 ~]# tput smul

#取消下划线
[root@135 ~]# tput rmu

tput用法详解-渐入佳境

设置突出显示字符

#突出模式,所有输出字符都突出显示
[root@135 ~]# tput rev

#突出模式,所有输出字符都突出显示
[root@135 ~]# tput smso

#取消突出模式
[root@135 ~]# tput rmso

tput用法详解-渐入佳境

4.1.3 光标属性

tput clear # 清屏
tput sc # 保存当前光标位置
tput cup 10 13 # 将光标移动到 row col
tput civis # 光标不可见
tput cnorm # 光标可见
tput rc # 显示输出
tpu init  清空格式

今天的文章tput用法详解-渐入佳境分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:http://bianchenghao.cn/57074.html

(0)
编程小号编程小号
上一篇 2023-08-25 23:11
下一篇 2023-08-25

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注