{"id":14128616,"url":"https://github.com/fboender/sshbg","last_synced_at":"2025-04-06T13:32:38.203Z","repository":{"id":37470631,"uuid":"104124779","full_name":"fboender/sshbg","owner":"fboender","description":"Change terminal background when SSH'ing (on specific terminals)","archived":false,"fork":false,"pushed_at":"2022-07-16T07:01:15.000Z","size":225,"stargazers_count":51,"open_issues_count":0,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-22T01:25:20.336Z","etag":null,"topics":["background","color","ssh","terminal","tilix","xterm"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fboender.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-19T20:25:45.000Z","updated_at":"2024-12-13T10:42:43.000Z","dependencies_parsed_at":"2022-07-12T15:50:31.883Z","dependency_job_id":null,"html_url":"https://github.com/fboender/sshbg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboender%2Fsshbg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboender%2Fsshbg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboender%2Fsshbg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboender%2Fsshbg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fboender","download_url":"https://codeload.github.com/fboender/sshbg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247488797,"owners_count":20946999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["background","color","ssh","terminal","tilix","xterm"],"created_at":"2024-08-15T16:01:56.665Z","updated_at":"2025-04-06T13:32:37.815Z","avatar_url":"https://github.com/fboender.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"sshbg\n=====\n\nChange terminal background color when SSH'ing.\n\n\u003cfont color=\"#FF0000\"\u003e**Important notice**\u003c/font\u003e: I do not provide support\nfor this repository. Please do not file feature requests for different\nterminals or bug reports if this setup does not work for you.\n\n![Demo](demo.gif)\n\n(Yes, all the hosts are actually localhost. I was lazy).\n\n## Supported emulators, caveat and problems\n\nThis **doesn't work** with:\n\n* Almost every terminal emulator in existence (Terminator, Gnome terminal,\n  XFCE terminal, anything based on libvte). **Update**: Seems to work now with\n  libvte v2.91+. Maybe older versions too.\n* When you're using `ControlMaster auto` in your SSH config.\n\nThe following terminal emulators are supported:\n\n* [Tilix](https://github.com/gnunn1/tilix) v1.7.7.\n* Xterm\n\nTo check if your terminal is supported, paste the following in your terminal:\n\n     echo -e \"\\033]11;#007F00\\a\"\n\nIf the background of your terminal changes to green, it is supported.\n\nTilix supported this in v1.7.7 and below. Since v1.7.7 it has been broken. See\n[this bugreport](https://github.com/gnunn1/tilix/issues/1759).  You can\ndowngrade to [v1.7.7](https://github.com/gnunn1/tilix/releases/tag/1.7.7) to\nget it working again.\n\n**Don't ask me for support for your specific terminal**. Chances are\nvery good that it can't be supported.\n\n\n## How does it work?\n\nBlack unix magic. Well, not really. Well, kinda...\n\nSSH lets you run a local command before the connection to the remote host is\nestablished. Some terminals allow you to set the background color with an\nescape sequence. It's possible to detect if the SSH command has exited from\nthe locally executed command by polling the parent process PID in the\nbackground. Combine the three and presto! Background colors.\n\nsshbg matches (regex) entries in a configuration file against the provided\nhostname. That results in a profile name, which has a background color\nassociated with it. See the \"Config file\" section at the bottom of this page\nfor more info.\n\n## Installation and usage\n\nRequirements:\n\n* Python v3.x+\n* A supported terminal\n\nClone this repo:\n\n    git clone git@github.com:fboender/sshbg.git\n    cd sshbg\n\nCopy the `sshbg` script to some dir in your PATH, for example:\n\n    sudo cp sshbg /usr/local/bin/\n\nCopy the `sshbg.conf` file to `~/.config/sshbg.conf`:\n\n    cp sshbg.conf ~/.config/\n\nEnable the `LocalCommand` configuration setting in your SSH config. You can do\nthis on a host-by-host basis, or with wildcards. To enable it for all hosts,\nmake your SSH config look like this:\n\n    $ cat ~/.ssh/config\n    PermitLocalCommand yes\n    Host *\n        LocalCommand sshbg \"%n\"\n\n## Config file\n\nThe config file is a JSON file that looks like this:\n\n    {\n        \"normal_bg_color\": \"#000000\",\n        \"profiles\": {\n            \"prod\": \"#2F0100\",\n            \"uat\": \"#1A1400\",\n            \"test\": \"#011A00\"\n        },\n        \"hostnames\": {\n            \"test.dev.local\": \"test\",\n            \"uat.dev.local\": \"uat\",\n            \"prod.dev.local\": \"prod\",\n            \".*-prod.*\": \"prod\",\n            \"acc.*\": \"uat\"\n        }\n    }\n\n\nThe keys:\n\n* `normal_bg_color`: The normal background color of your terminal, which\n  sshbg will reset your terminal to when the SSH command returns.\n* `profiles`: The list of profile names and their associated colors. You\n  can name these whatever you want.\n* `hostnames`: Regular expressions that are matched against the hostname\n  you're SSH'ign too. If the regex matches, the profile is selected.\n\n## Remarks, weirdness and bugs.\n\n* The hostname is the one you specify on the commandline, **NOT** necessarily\n  the real remote hostname.\n* Manually chained SSH (`ssh machine_a -\u003e ssh machine_b`) will not work.\n  Automatically chained SSH (through `ProxyCommand`) *will* work.\n* When SSH exits, the terminal background color is reset to the value of\n  `normal_bg_color` in the configuration file. I have not yet found a way to\n  reset the original terminal color as defined in your terminal.\n* After the background color is set by sshbg, your terminal probably can't\n  change the background color itself anymore. No idea why.\n* Probably a million different strange behaviours. Did I mention I don't\n  support this project already?\n\n## License\n\nMIT license. See `LICENSE` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffboender%2Fsshbg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffboender%2Fsshbg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffboender%2Fsshbg/lists"}