Skip to content

Instantly share code, notes, and snippets.

@kontza
Last active October 10, 2022 11:36
Show Gist options
  • Save kontza/f47acaaef6260bcc8a4b6907f9313366 to your computer and use it in GitHub Desktop.
Save kontza/f47acaaef6260bcc8a4b6907f9313366 to your computer and use it in GitHub Desktop.
Change macOS iTerm background its font name and size based on the desired ssh hostname. This script is named `ssc` so that I can SSH into some host without these tweaks.
#!/opt/local/bin/fish
function set_bg
osascript -e "tell application \"Terminal\" to set background color of window 1 to $argv[1]"
end
function set_profile
osascript -e "tell application \"Terminal\" to set current settings of window 1 to settings set \"$argv[1]\""
end
function set_iterm_bg
echo -e "\033]1337;SetColors=bg=$argv[1]\a"
end
function clear_iterm_bg
echo -e "\033]1337;SetProfile=Default\a"
end
function victor_forza # Force font name and size
osascript -e "tell application \"Terminal\" to set the font name of window 1 to \"Victor Mono Regular\""
osascript -e "tell application \"Terminal\" to set the font size of window 1 to 14"
end
function on_exit
# set_profile "Basic"
clear_iterm_bg
end
# Trap both regular exit & Ctrl-C.
trap on_exit EXIT
trap on_exit INT
for element in "$argv"
switch $element
case "*prod01"
# set_profile "Red Sands"
set_iterm_bg 8b0000
case "*qa01"
# set_profile "Ocean"
set_iterm_bg 007070
case "management*"
# set_profile "Novel"
set_iterm_bg A0522D
end
end
/usr/bin/ssh $argv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment