linux - 临时清除 tty
问题描述
许多命令(例如watch
,less
)能够暂时清除 tty 以显示全屏信息,然后在命令退出时恢复原始 tty 内容。
有没有办法在 bash 脚本中实现这一点?
解决方案
使用 tput。这是一个最小的例子:
#!/bin/bash
tput smcup # save the screen
clear # clear the screen
echo this is some text on a blank screen
echo press any button to exit..
read -n1
tput rmcup # reset the screen
推荐阅读
- python - pytorch 版本 0.3.1.post2 的设置设备
- c# - 如何:获取游戏对象的实例
- slack-api - 从机器人创建交互式消息
- .net-core - 正确管理解决方案之间的私有 nuget 包依赖关系
- android - 如何在 Flutter 中实现类似 iOS 的平滑页面过渡动画?
- graph - Cypher allShortestPaths 只返回一条路径?
- javascript - Draw.io:如何调试未压缩的 js 代码?
- node.js - 在 S3 中允许公共读取和存储桶所有者完全控制
- sql-server - 使用混合连接从应用服务到本地 SQL Server 的 Sqlcmd
- javascript - 如何使用javascript计算出哪个变量的字符最多