0
点赞
收藏
分享

微信扫一扫

2.Pandas数据预处理

除了stty命令,我们还可以使用tput命令来更改终端的参数和功能。

1 tput 命令的功能

tput 命令的主要功能有:移动更改光标、更改文本显示属性(如颜色、下划线、粗体),清除屏幕特定区域等。

2 tput 命令格式

 

3 设置文本颜色属性

3.1 tput setaf / setbf :设置前景色 / 背景色

命令格式:


例子:设置前背景色为黄色(3),背景色为品红(5)。

看来不能在一个命令中同时设置前景色和背景色,要分开来用两个命令分别设置。

3.2 tput rev:反显当前的颜色方案

rev源自reverse。


4 设置文本模式属性

命令功能
tput bold加粗字体
tput dim打开高亮模式,turn on half-bright mode
tput smul添加下划线,start mode of underline,
tput rmul 取消下划线,remove mode of underline
tput smso突出模式,start mode of standout
tput rmso反显突出模式,reverse mode of standout
tput sgr0set global attributes return to 0, 取消所有属性

5 设置光标属性

命令功能
tput clear清屏
tput sc保存当前光标位置,save curosr position
tput rc恢复光标位置,restore cursor postion
tput cup row column将光标移动到指定行row和列column,
tput civis 光标不可见,cursor invisible
tput cnorm光标可见,cursor mormal
tpu init清空格式

我们将执行以下命令序列:

tput clear                   # 清屏
tput sc                      # 保存当前光标位置
tput cup 10 13               # 将光标移动到第10行第13列
echo -n Enter your password: # 提示用户输入密码
tput civis                   # 光标不可见
read p                       # 将用户输入的密码保存到变量p中
tput cnorm                   # 光标可见
tput rc                      # 恢复光标位置
echo your password: $p       # 显示用户输入的密码

 

6 其它功能

命令功能
tput lines 显示行数
tpus cols显示列数
tput reset  重置终端设置
tput longname显示当前终端类型的长名称
tput hs        具有状态行

 

举报

相关推荐

0 条评论