All Projects → fboender → sshbg

fboender / sshbg

Licence: MIT license
Change terminal background when SSH'ing (on specific terminals)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to sshbg

nord-tilix
An arctic, north-bluish clean and elegant Tilix color scheme.
Stars: ✭ 105 (+133.33%)
Mutual labels:  color, tilix
react-scrolling-color-background
background with color transitioning as you scroll, declarative and easy to setup
Stars: ✭ 53 (+17.78%)
Mutual labels:  color, background
tempus-themes
[Mirror] Tempus is a collection of themes for Vim, text editors, and terminal emulators that are compliant at the very least with the WCAG AA accessibility standard for colour contrast
Stars: ✭ 48 (+6.67%)
Mutual labels:  xterm, tilix
react-native-dual
ScrollView, FlatList, SectionList and ListView with dual background
Stars: ✭ 28 (-37.78%)
Mutual labels:  color, background
Django Colorfield
color field for django models with a nice color-picker in the admin. 🎨
Stars: ✭ 238 (+428.89%)
Mutual labels:  color
Rainbow
🌈 Colorize commands output or STDIN using patterns.
Stars: ✭ 217 (+382.22%)
Mutual labels:  color
Contrast Swatch
🅰️ Image microservice for color contrast information
Stars: ✭ 210 (+366.67%)
Mutual labels:  color
Uigradient
A simple and powerful library for using gradient layer, image, color
Stars: ✭ 208 (+362.22%)
Mutual labels:  color
ChromaTerm
Color your Terminal with RegEx!
Stars: ✭ 149 (+231.11%)
Mutual labels:  color
Get Childitemcolor
Add coloring to the output of Get-ChildItem Cmdlet of PowerShell.
Stars: ✭ 251 (+457.78%)
Mutual labels:  color
Color Space
Math & data behind color spaces and color conversions.
Stars: ✭ 232 (+415.56%)
Mutual labels:  color
Dynamic Support
A complete library to build Android apps with a built-in theme engine.
Stars: ✭ 218 (+384.44%)
Mutual labels:  color
Nord Alacritty
An arctic, north-bluish clean and elegant Alacritty color scheme.
Stars: ✭ 238 (+428.89%)
Mutual labels:  color
Xcolor
Lightweight color picker for X11
Stars: ✭ 209 (+364.44%)
Mutual labels:  color
Colorizeswift
Terminal string styling for Swift.
Stars: ✭ 253 (+462.22%)
Mutual labels:  color
Colors.lol
🎨 Overly descriptive color palettes
Stars: ✭ 207 (+360%)
Mutual labels:  color
Sketch
Sketch have a lot of basic functions to develop a drawing app for iPhone. Anyone can easily create drawing iOS Application.
Stars: ✭ 229 (+408.89%)
Mutual labels:  color
Hexbot
Every request returns a different hex code—all 16,777,216 of them.
Stars: ✭ 251 (+457.78%)
Mutual labels:  color
Dynamiccolor
Yet another extension to manipulate colors easily in Swift and SwiftUI
Stars: ✭ 2,677 (+5848.89%)
Mutual labels:  color
Php Console Spinner
Colorful highly configurable spinner for php cli applications (suitable for async apps)
Stars: ✭ 225 (+400%)
Mutual labels:  color

sshbg

Change terminal background color when SSH'ing.

Important notice: I do not provide support for this repository. Please do not file feature requests for different terminals or bug reports if this setup does not work for you.

Demo

(Yes, all the hosts are actually localhost. I was lazy).

Supported emulators, caveat and problems

This doesn't work with:

  • Almost every terminal emulator in existence (Terminator, Gnome terminal, XFCE terminal, anything based on libvte). Update: Seems to work now with libvte v2.91+. Maybe older versions too.
  • When you're using ControlMaster auto in your SSH config.

The following terminal emulators are supported:

To check if your terminal is supported, paste the following in your terminal:

 echo -e "\033]11;#007F00\a"

If the background of your terminal changes to green, it is supported.

Tilix supported this in v1.7.7 and below. Since v1.7.7 it has been broken. See this bugreport. You can downgrade to v1.7.7 to get it working again.

Don't ask me for support for your specific terminal. Chances are very good that it can't be supported.

How does it work?

Black unix magic. Well, not really. Well, kinda...

SSH lets you run a local command before the connection to the remote host is established. Some terminals allow you to set the background color with an escape sequence. It's possible to detect if the SSH command has exited from the locally executed command by polling the parent process PID in the background. Combine the three and presto! Background colors.

sshbg matches (regex) entries in a configuration file against the provided hostname. That results in a profile name, which has a background color associated with it. See the "Config file" section at the bottom of this page for more info.

Installation and usage

Requirements:

  • Python v3.x+
  • A supported terminal

Clone this repo:

git clone [email protected]:fboender/sshbg.git
cd sshbg

Copy the sshbg script to some dir in your PATH, for example:

sudo cp sshbg /usr/local/bin/

Copy the sshbg.conf file to ~/.config/sshbg.conf:

cp sshbg.conf ~/.config/

Enable the LocalCommand configuration setting in your SSH config. You can do this on a host-by-host basis, or with wildcards. To enable it for all hosts, make your SSH config look like this:

$ cat ~/.ssh/config
PermitLocalCommand yes
Host *
    LocalCommand sshbg "%n"

Config file

The config file is a JSON file that looks like this:

{
    "normal_bg_color": "#000000",
    "profiles": {
        "prod": "#2F0100",
        "uat": "#1A1400",
        "test": "#011A00"
    },
    "hostnames": {
        "test.dev.local": "test",
        "uat.dev.local": "uat",
        "prod.dev.local": "prod",
        ".*-prod.*": "prod",
        "acc.*": "uat"
    }
}

The keys:

  • normal_bg_color: The normal background color of your terminal, which sshbg will reset your terminal to when the SSH command returns.
  • profiles: The list of profile names and their associated colors. You can name these whatever you want.
  • hostnames: Regular expressions that are matched against the hostname you're SSH'ign too. If the regex matches, the profile is selected.

Remarks, weirdness and bugs.

  • The hostname is the one you specify on the commandline, NOT necessarily the real remote hostname.
  • Manually chained SSH (ssh machine_a -> ssh machine_b) will not work. Automatically chained SSH (through ProxyCommand) will work.
  • When SSH exits, the terminal background color is reset to the value of normal_bg_color in the configuration file. I have not yet found a way to reset the original terminal color as defined in your terminal.
  • After the background color is set by sshbg, your terminal probably can't change the background color itself anymore. No idea why.
  • Probably a million different strange behaviours. Did I mention I don't support this project already?

License

MIT license. See LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].