summaryrefslogtreecommitdiff
path: root/bin/cursor
blob: 6a98d41f459e8d6a9acb34716944a3ac9721f10b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash

# Set cursor in xterm and compatibles.

usage="Usage: $0 [black | blue | cyan | gray | green | magenta | orange | red | white | yellow]"

cursor() {
	case $1 in
		(0|r|red)     set -- '#f00' ;;
		(1|n|green)   set -- '#5f5' ;;
		(2|b|blue)    set -- '#55f' ;;
		(3|c|cyan)    set -- '#0ff' ;;
		(4|y|yellow)  set -- '#ff0' ;;
		(5|m|magenta) set -- '#f0f' ;;
		(6|o|orange)  set -- '#f80' ;;
		(7|g|gr[ae]y) set -- '#888' ;;
		(k|black)     set -- '#111' ;;
		(w|white)     set -- '#eee' ;;
	esac
	printf '\e[2 q\e]12;'$1'\e\' # set non blinking block, then color
}

case $1 in -*) echo "$usage" >&2; exit 1;; esac
cursor "${1:-$((RANDOM % 8))}"