8

How to Make the OS X Terminal Change Colors for Remote Servers

 3 years ago
source link: http://hacksoflife.blogspot.com/2019/11/how-to-make-os-x-terminal-change-colors.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to Make the OS X Terminal Change Colors for Remote Servers

A thing I have done is attempt to hard shut down my Mac using the shell (e.g. sudo shutdown -r) and accidentally taken down one of our servers that I was ssh'd into.

To fix this and generally have more awareness of what the heck I am doing, I use a .profile script to change the Terminal theme when logging into and out of remote servers via SSH.

echo BashRC
function tabc {
  NAME=$1; if [ -z "$NAME" ]; then NAME="Default"; fi
  osascript -e "tell application \"Terminal\" to set current settings of front window to settings set \"$NAME\""
function ssh {
  tabc "Pro"
  /usr/bin/ssh "$@"
  tabc "Basic"

I am not sure where this comes from - possibly here, but I see a few web references and I don't know which one I originally found. I'm posting it here so that I can find it the next time I get a new machine.

(Redoing this was necessary because I didn't migration-assistant my new laptop, and since it was going to Catalina, that was probably for the best.)
The script goes into ~/.profile for OS X 10.14 and older, or ~/.zprofile for OS X 10.15.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK