Enlarge font with iterm2 and tmux
I've tried just about everything to figure out a way to automatically bump up the font size much larger when I hit a hot key in tmux by triggering a script. Only thing I got working is this which is very hacky and slow:
#!/usr/bin/env bash
osascript -e '
tell application "System Events" to keystroke "++++++++++++++++++++" using command down
'
This works but only with shell integration:
echo -e "\033]50;SetProfile=Development_Large\a"
But the problem is shell integration does not work with tmux.
Anything else I can do? I've tried applescript to change the current profile but I could not get any of them to work. Example:
osascript -e "
tell application \"iTerm2\"
tell current window
tell current tab
set profile to \"cheat\"
end tell
end tell
end tell
"
This script just outputs "cheat" to the terminal.
Is there something else I might try?
I hit upon a solution:
Step 1: In iterm, open the preferences panel for the profile you will be switching from
Step 2: Click on the "Keys" tab for the profile
Step 3: Add a new key mapping by clicking on the plus sign.
Step 4: Choose the "keyboard shortcut" as desired and under "action", select "change profile". Now select the profile you want to switch to. Click "OK"
Step 5: Use something like the following bash script to trigger the key mapping:
osascript -e 'tell application "System Events" to keystroke "z" using {command down,control down}'
You will need to modify this script to use your chosen hotkey.
One other very useful but somewhat unrelated tip for modifying fonts is to give tmux the "resize-window" command to fix the window size. This prevents the panes from resizing when switching font sizes.