mik*_*iku 21
本节介绍ANSI转义序列:
例子:
echo -en "\033[s\033[7B\033[1;34m 7 lines down violet \033[u\033[0m"
echo -en "\033[s\033[7A\033[1;32m 7 lines up green \033[u\033[0m"
Run Code Online (Sandbox Code Playgroud)
本节介绍tput实用程序:
有关演示,请参阅终端中的浮动时钟:
从http://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html获取的示例脚本:
#!/bin/bash
tput clear # clear the screen
tput cup 3 15 # Move cursor to screen location X,Y (top left is 0,0)
tput setaf 3 # Set a foreground colour using ANSI escape
echo "XYX Corp LTD."
tput sgr0
tput cup 5 17
tput rev # Set reverse video mode
echo "M A I N - M E N U"
tput sgr0
tput cup 7 15; echo "1. User Management"
tput cup 8 15; echo "2. Service Management"
tput cup 9 15; echo "3. Process Management"
tput cup 10 15; echo "4. Backup"
tput bold # Set bold mode
tput cup 12 15
read -p "Enter your choice [1-4] " choice
tput clear
tput sgr0
tput rc
Run Code Online (Sandbox Code Playgroud)

使用echo将限制您使用特定的终端类型.最好使用tput.
tput cup 10 4; echo there
Run Code Online (Sandbox Code Playgroud)
将光标放在第10行第4列并在该位置打印"那里".
对于更基本的移动,您必须tput cub1向左tput cuf1移动,向右tput cuu1移动,向上tput cud1移动以及向下移动光标.
| 归档时间: |
|
| 查看次数: |
19018 次 |
| 最近记录: |