summaryrefslogtreecommitdiff
path: root/bin/cursor
diff options
context:
space:
mode:
Diffstat (limited to 'bin/cursor')
-rwxr-xr-xbin/cursor30
1 files changed, 16 insertions, 14 deletions
diff --git a/bin/cursor b/bin/cursor
index 6fdbc12..537c164 100755
--- a/bin/cursor
+++ b/bin/cursor
@@ -1,22 +1,24 @@
-#!/bin/bash
+#!/bin/sh
# Set cursor in xterm and compatibles.
+usage="Usage: $0 [black | blue | cyan | gray | green | magenta | orange | red | white | yellow]"
+
cursor() {
case $1 in
- (r|red) cc='#f00' ;;
- (n|green) cc='#5f5' ;;
- (b|blue) cc='#55f' ;;
- (c|cyan) cc='#0ff' ;;
- (y|yellow) cc='#ff0' ;;
- (m|magenta) cc='#f0f' ;;
- (o|orange) cc='#f80' ;;
- (k|black) cc='#111' ;;
- (g|gr[ae]y) cc='#888' ;;
- (w|white) cc='#eee' ;;
- (*) cc=$1 ;;
+ (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
}
-cursor "${1:-red}"
-printf '\e]12;'$cc'\e\' # set cursor color
+case $1 in -*) echo "$usage" >&2; exit 1;; esac
+cursor "${1:-$((RANDOM % 8))}"