Last active
November 3, 2021 16:11
-
-
Save wangchen/18b037ceb009fcb0df87 to your computer and use it in GitHub Desktop.
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
# Usage: | |
# Change profile when using ssh. | |
# You MUST define a profile named 'ForSSH' with diferent settings. | |
# I am using color schemes with different background color. | |
# Then: | |
# $ save as ~/.iterm2.zsh | |
# $ echo ". ~/.iterm2.zsh" >> ~/.zshrc | |
# iTerm2 window/tab color commands | |
# Requires iTerm2 >= Build 1.0.0.20110804 | |
# http://iterm2.com/documentation-escape-codes.html | |
profile-change() { | |
echo -ne "\033]50;SetProfile=ForSSH\a" | |
echo -ne "\033]50;SetProfile=ForSSH\a" | |
} | |
profile-reset() { | |
echo -ne "\033]50;SetProfile=Default\a" | |
} | |
# Change the color of the tab when using SSH | |
# reset the color after the connection closes | |
color-ssh() { | |
if [[ -n "$ITERM_SESSION_ID" ]]; then | |
trap "profile-reset" INT EXIT | |
profile-change | |
fi | |
ssh $* | |
} | |
compdef _ssh color-ssh=ssh | |
alias ssh=color-ssh |
Hello, does this still work? It used to work but it stopped lately...
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's inspired by https://gist.github.com/wadey/1140259