Dynamically colored windows based on hostname, IP, or SSH configuration
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
LICENSE
README.rst
bash_test_rc.sh
painted-colors.png
painted-config.png
painted_iterm_include.sh
test.sh

README.rst

Overview

painted-iterm allows you to configure the color of your iTerm2 windows based on the hostname, IP, or SSH configuration. This allows you to color code your windows to help prevent errors. It supports 256 colors.

Install

  1. Install Homebrew — The missing package manager for OS X

  2. Add the "tap":

    brew tap TimZehta/tap
    
  3. Install painted-iterm:

    brew install painted-iterm
    
  1. iTerm2 > Preferences > Appearance: Enable "Show Border around window"

SSH Configuration

The SSH configuration is the easiest way to configure iTerm2 window colors. It is also the only way to do so for appliances that don't have a bash shell. The SSH configuration is most commonly done only locally in ~/.ssh/config.

The following example paints the iTerm2 window color of prod-firewall bright red and paints the iTerm2 window color of dev-server green:

Host prod-firewall
    HostName prod-firewall.example.com
    User admin
    LocalCommand painted-ansi 1

Host dev-server
    HostName dev-server.example.com
    User admin
    LocalCommand painted-label DEV

Host *
    PermitLocalCommand yes

The painted-label example requires the .bashrc configuration below (so that the PAINTED_CONFIG varible is available).

.bashrc Configuration

The following .bashrc excerpt configures a traffic light environment scheme used at many shops:

export TERM=xterm-256color

# Label             Match Pattern                               ANSI Color
export PAINTED_CONFIG='
Laptop              ^lappy$                                     8
Bastions            ^bastion                                    52
Office              ^192\.168\.0\.                              18
DMZ                 ^10\.10\.10\.                               202
PROD                ^10\.10\.20\.                               1
DEV                 ^10\.10\.30\.|^10\.33\.33\.                 28
last_default        .                                           11
'
source .painted_iterm_include.sh

The configured .bashrc and .painted_iterm_include.sh must exist on the remote host.

Helper Functions and Scripts

bin/painted-ansi :
paints window color based on ANSI color code.
bin/painted-label :
paints window color based on configured label (requires export of PAINTED_CONFIG).
bin/painted-rgb :
paints window color based on R G B values.
bin/painted-colors :
shows 256 ANSI color codes.
painted-config (function) :
shows currently configured paint scheme (outputs formatted PAINTED_CONFIG provided your .bashrc is configured correctly)

Screenshots

painted-colors screenshot painted-config screenshot

Resources

Requirements

License