Last active
April 22, 2025 02:28
-
-
Save ernix/755223 to your computer and use it in GitHub Desktop.
Set OSX terminal window background color per SSH hosts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Set TMUX terminal pane background color per SSH hosts | |
# alias ssh='path/to/vsh.sh' | |
_ssh_tmux_background () { | |
[ -z "$TMUX_PANE" ] && return 0 | |
if [ -n "$1" ]; then | |
hostname=$(command ssh -G "$@" | awk '$1=="hostname" { print $2; }') | |
case "$hostname" in | |
*.example.com) | |
# blue | |
style='bg=colour52' | |
;; | |
*.example.net) | |
# red | |
style='bg=colour17' | |
;; | |
esac | |
else | |
style=default | |
fi | |
tmux set-option -p -t "$TMUX_PANE" window-style "$style" | |
tmux set-option -p -t "$TMUX_PANE" window-active-style "$style" | |
} | |
_ssh_tmux_background "$@" # Parse Host | |
trap '_ssh_tmux_background' 0 1 2 3 15 | |
command ssh "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment