TODO ANSI Color Code
True Colour (16 million colours) support in various terminal applications and terminals
\e[31m \033[31m
\e[0m \033[0m
移动光标的转义序列
- Position the Cursor: \033[<L>;<C>H Or \033[<L>;<C>f puts the cursor at line L and column C. - Move the cursor up N lines: \033[<N>A - Move the cursor down N lines: \033[<N>B - Move the cursor forward N columns: \033[<N>C - Move the cursor backward N columns: \033[<N>D - Clear the screen, move to (0,0): \033[2J - Erase to end of line: \033[K - Save cursor position: \033[s - Restore cursor position: \033[u
实现进度条
#!/bin/bash echo -n '------------------------------------------' echo -n -e "\r" # 移动光标到行首 while true; do echo -n -e '\033[1C' # 光标向后移动一位 echo -n -e '\b' # 删簇一个字符 echo -n '#' # 打印一个井号 sleep 0.5 # 休眠 500ms done
参考文献
Wikipedia/ANSI escape code
Bash tips: Colors and formatting (ANSI/VT100 Control sequences)