summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2024-12-05 11:15:48 +0100
committerMarc Vertes <mvertes@free.fr>2024-12-05 11:15:48 +0100
commitdc34a54fc594a2fdc5854d5f55ceb64c39823db0 (patch)
tree69a1ab7b9406262e15cff80b3503d934f2a2fbba
parent4912d5f2c9f05b5839c8fcf514b4453f24669cbe (diff)
fixup
-rwxr-xr-xbin/tc3
-rwxr-xr-xbin/tf32
2 files changed, 34 insertions, 1 deletions
diff --git a/bin/tc b/bin/tc
index f73d109..278ca3f 100755
--- a/bin/tc
+++ b/bin/tc
@@ -12,9 +12,10 @@ color() {
(5|n|green) bg='#e0ffe0' ;;
(6|o|orange) bg='#fff0f4' ;;
(7|k|black) bg='#111111' fg='#eeeeee' ;;
+ (*) echo "$0: unknown color $1">&2; exit 1 ;;
esac
}
color ${1:-$((RANDOM % 7))}
-printf '\E]11;'$bg'\E\'
+printf '\E]11;'${bg:-#ffffff}'\E\'
printf '\E]10;'${fg:-#000000}'\E\'
diff --git a/bin/tf b/bin/tf
new file mode 100755
index 0000000..e0f18bf
--- /dev/null
+++ b/bin/tf
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# Set terminal font. Only Macos Terminal is supported for now.
+
+die() { echo ${@} >&2; exit 1; }
+
+terminal_font() {
+ case $1 in
+ (m|menlo|mono) fn=menlo fs=$2 ;;
+ (f|fixed|6x13) fn=6x13 fs=13 ;;
+ ([0-9]*) fs=$1 ;;
+ (*) fn=$1 fs=$2 ;;
+ esac
+
+ [ "$fn" ] && osascript -e "tell application \"Terminal\" to set font name of window 1 to \"$fn\""
+ [ "$fs" ] && osascript -e "tell application \"Terminal\" to set font size of window 1 to $fs"
+}
+
+iterm2_font() {
+ case $1 in
+ (m|menlo|mono) p='Marc' ;;
+ (f|fixed|6x13) p='marc light fixed' ;;
+ (*) die 'not supported' ;;
+ esac
+ printf "\E]50;SetProfile=$p\a"
+}
+
+case $TERM_PROGRAM in
+ (Apple_Terminal) terminal_font $@ ;;
+ (iTerm.app) iterm2_font $@ ;;
+ (*) die 'not supported' ;;
+esac