summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2025-01-06 18:01:45 +0100
committerMarc Vertes <mvertes@free.fr>2025-01-06 18:01:45 +0100
commitf130384cd8e7f894a29b6412ea36b31f72d4e771 (patch)
tree2a61e7aba8e0d3ef79757326649d356b7aaf6053 /bin
parent270699d4eb1f1d27e2d8905cfbbf0037f07609ed (diff)
update
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cursor30
-rwxr-xr-xbin/tc11
2 files changed, 23 insertions, 18 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))}"
diff --git a/bin/tc b/bin/tc
index 12129af..e2e34a4 100755
--- a/bin/tc
+++ b/bin/tc
@@ -1,7 +1,9 @@
-#!/bin/bash
+#!/bin/sh
# Set terminal color in xterm and compatibles
+usage="Usage: $0 [black | blue | cyan | gray | green | magenta | orange | red | white | yellow]"
+
color() {
case $1 in
(0|w|white) bg='#ffffff' ;;
@@ -11,10 +13,11 @@ color() {
(4|y|yellow) bg='#ffffe0' ;;
(5|n|green) bg='#e0ffe0' ;;
(6|o|orange) bg='#fff0f4' ;;
- (7|k|black) bg='#111111' fg='#eeeeee' ;;
+ (7|k|black) bg='#000000' fg='#eeeeee' ;;
esac
+ printf '\e]11;'${bg:-#ffffff}'\e\' # Set background color.
+ printf '\e]10;'${fg:-#000000}'\e\' # Set foreground color.
}
+case $1 in -*) echo "$usage" >&2; exit 1;; esac
color ${1:-$((RANDOM % 7))}
-printf '\E]11;'${bg:-#ffffff}'\E\' # Set background color.
-printf '\E]10;'${fg:-#000000}'\E\' # Set foreground color.