How can an application running in a Terminal.app window change its window's font size? No solution (such as a system call to applescript, etc) too odd!
Asked
Active
Viewed 799 times
1 Answers
2
It's relatively simple to do this; the only real caveat is that you might need to adjust the window size if you want it to remain consistent with it's proportions, since the font size seems to affect it.
Applescript called from Bash:
#!/bin/bash
osascript <<EOF
tell application "System Events"
tell process "Terminal"
set frontmost to true
end tell
end tell
tell application "Terminal"
set font size of first window to "11"
delay 1.0
set font size of first window to "14"
end tell
EOF
This shows about the most basic example which should work for anything currently active within a Terminal
window. Applescript is ideal for this type of thing, however, if the font sizing requires a lot of typographic manipulation then you might need to consider something different.
If you're interested in additional Terminal window adjustments I've listed some others here.

l'L'l
- 44,951
- 10
- 95
- 146
-
Note that the first window in Terminal is not necessarily the one running that script. – Ken Thomases Aug 03 '15 at 19:41
-
@KenThomases, True - in which case using `window frontmost` might be better, however, that's not a certainty either; if you have any other suggestions I'm all ears. – l'L'l Aug 03 '15 at 23:47
-
`first window` is the frontmost window. I don't have any great suggestion. If the program's name is distinctive and the Terminal is configured to put the executable name in the window's title, the window could be found by title. Similarly, there are tty control codes to set the window title. The program could use those and find its window that way. – Ken Thomases Aug 04 '15 at 03:43
-
2For my case this will be run in an interactive command loop, so this will work just fine for me. Many thanks!! – Mark Harrison Aug 04 '15 at 04:36
-
@MarkHarrison: You're welcome, I'm glad it's what you were looking for! I also figured out an easy way to adjust the window size back to it's original bounds once the font size changed (I prefer the window to remain the same size): https://gist.github.com/anonymous/c8e52f676fc625e219d5 – l'L'l Aug 04 '15 at 07:41