标签:
#!/bin/bash XY=(1 1) OP=(1 1) YR=(2 0 1 5) get_window_size() { echo -ne "\e[2J" SZ=($(stty -a | tr ‘;‘ ‘\n‘ | awk ‘/rows|columns/{print $2}‘)) } echo -ne "\e[?1049h\e[?25l" trap ‘echo -ne "\e[?1049l\e[?25h"; exit‘ INT get_window_size trap get_window_size WINCH if which usleep >/dev/null; then SLEEP="usleep 10000" else SLEEP="sleep 0.01" fi while :; do echo -ne "\e[3$((z++%7+1))m\e[${XY[0]};${XY[1]}H${YR[$((y++%4))]}\e[0m" for i in 0 1; do if (( OP[i] == 1 )); then if ((XY[i] < SZ[i])); then ((++XY[i])) else ((XY[i]=SZ[i]-1, OP[i]=0)) fi else if ((XY[i] > 1)); then ((--XY[i])) else ((XY[i]=2, OP[i]=1)) fi fi done $SLEEP done
玩具脚本 改变窗口大小时重绘 按Ctrl+C退出
标签:
原文地址:http://my.oschina.net/2bit/blog/363468