Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Changing terminal color in MacOSX when SSHing
# Changing terminal color in MacOSX when SSHing (so you know at a glance that you're no longer in Kansas)
# Adapted from
# 1. Create a theme in your terminal setting with the name "SSH" and the desired colors, background, etc.
# 2. Add this to your .bash_profile (or .bashrc, I always forget the difference ;))
# 3. Optional but useful: in the terminal, go to Settings > Startup and set "New tabs open with" to
# "default settings" (otherwise, if you open a new tab from the changed one, you get a local tab with
# the SSH colors)
function tabc() {
NAME=$1; if [ -z "$NAME" ]; then NAME="Default"; fi # if you have trouble with this, change
# "Default" to the name of your default theme
osascript -e "tell application \"Terminal\" to set current settings of front window to settings set \"$NAME\""
function colorssh() {
tabc SSH
ssh $*
alias ssh="colorssh"
# This would be easy to extend to check if a theme with the name of the server exists and set it, and
# fall back to the SSH theme. This way you can have different colors for different remote environments
# (per project, production, staging, etc.)

This comment has been minimized.

Copy link

littlewine commented Dec 9, 2019

I am getting the following weird error:
execution error: Terminal got an error: Can’t set settings set "SSH" to settings set "SSH".

any idea whats wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.