summaryrefslogtreecommitdiff
path: root/bin/tf
blob: a56623363b0e529299a4f5f8dc61d02dd2d85d6c (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
25
26
27
28
29
30
31
32
33
#!/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 ;;
		(s|sf)         fn='SF Mono Light' fs=8 ;;
		([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