shell编程 - 终端设置

1. 获取终端信息

# 获取终端的列数
tput cols
# 获取终端的行数 
tput lines
# 获取终端名称
tput longname

2. 移动光标

# 移动光标到(10,80)处
tput cup 10 80

3. 设置终端

# 设置背景色
tputsetb n  # n为0-7的数字
# 设置文本前景色
tputsetf n  # n为0-7的数字
# 设置文本样式为粗体
tput bold

4. 设置下划线

# 设置下划线开始
tput smul
# 设置下划线结束
tput rmul

5. 删除内容

# 删除从当前光标位置到行尾的所有内容
tputed

6. stty 禁止输出到终端

echo -e "Enter password: "
# 禁止将输出发送到终端
stty -echo 
read password
# 允许将输出发送到终端
stty echo
echo 
echo "the password is $password"
posted @   箫笛  阅读(80)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
历史上的今天:
2020-03-31 Bash命令 —— colrm
2020-03-31 Bash 命令 —— rev
2020-03-31 Bash 命令 —— tac
2020-03-31 Bash 命令 —— split
2020-03-31 Bash 命令 —— tr
点击右上角即可分享
微信分享提示