All Projects → rocky → shell-term-background

rocky / shell-term-background

Licence: GPL-2.0 License
POSIX shell scripts to figure out if a terminal has a dark or light background

Programming Languages

shell
77523 projects
perl
6916 projects
python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to shell-term-background

vscode-fortran-support
Fortran language support for Visual Studio Code
Stars: ✭ 49 (+188.24%)
Mutual labels:  debugger
LRDB
Lua Remote DeBugger
Stars: ✭ 50 (+194.12%)
Mutual labels:  debugger
kshdb
Korn Shell (93v- 2014-12-24 or greater) Debugger
Stars: ✭ 24 (+41.18%)
Mutual labels:  debugger
Devel-hdb
A graphical Perl debugger implemented as a web service
Stars: ✭ 29 (+70.59%)
Mutual labels:  debugger
rusty-boy
Gameboy emulator in Rust
Stars: ✭ 20 (+17.65%)
Mutual labels:  debugger
go6502
6502 CPU emulator, assembler and disassembler written in Go
Stars: ✭ 31 (+82.35%)
Mutual labels:  debugger
debug.js
Debugger of JavaScript, by JavaScript, for JavaScript
Stars: ✭ 19 (+11.76%)
Mutual labels:  debugger
madbomber
Backtrace-on-throw C++ exception logger
Stars: ✭ 17 (+0%)
Mutual labels:  debugger
lsp-wl
A Wolfram Language Server
Stars: ✭ 157 (+823.53%)
Mutual labels:  debugger
shell-toolbox
Useful shell scripts for /bin/sh
Stars: ✭ 40 (+135.29%)
Mutual labels:  posix-sh
objeck-lang
Modern object-oriented and functional programming language
Stars: ✭ 45 (+164.71%)
Mutual labels:  debugger
edd
Erlang Declarative Debugger
Stars: ✭ 20 (+17.65%)
Mutual labels:  debugger
Emux
GameBoy emulator written in C#
Stars: ✭ 58 (+241.18%)
Mutual labels:  debugger
z80e
A z80 calculator emulator (and debugger)
Stars: ✭ 65 (+282.35%)
Mutual labels:  debugger
WeConsole
功能全面、界面与体验对标 Chrome devtools 的可定制化的小程序开发调试面板
Stars: ✭ 137 (+705.88%)
Mutual labels:  debugger
BrainfuckIDE
A Brainfuck IDE/debugger designed to be intuitive, featureful and visually appealing
Stars: ✭ 77 (+352.94%)
Mutual labels:  debugger
lldb debugger
Helpful commands when using lldb.
Stars: ✭ 27 (+58.82%)
Mutual labels:  debugger
gdbstub
An ergonomic and easy-to-integrate implementation of the GDB Remote Serial Protocol in Rust, with full no_std support.
Stars: ✭ 158 (+829.41%)
Mutual labels:  debugger
usbdm-firmware
Firmware for USBDM BDMs
Stars: ✭ 33 (+94.12%)
Mutual labels:  debugger
lkmd
Linux Kernel Module Debugger
Stars: ✭ 13 (-23.53%)
Mutual labels:  debugger

Pypi Installs Latest Version Supported Python Versions

The Python module contained is part of a broader set of scripts

For the shell scripts, if you source this from a shell session it will set and export COLORFGBG to 0;15 for dark backgrounds and 15;0 for light backgrounds which is a convention used by some programs. Since I find this a little arcane, the program also sets and exports LC_DARK_BG to 1 for dark backgrounds and 0 for light. The LC_ (locale) assists in some ssh configurations which often will let environment variables with that prefix get passed along and set to a remote ssh session.

From Python you can call term_background.is_dark_background() which returns a True if we think the background is dark.

The heuristics used is to try to query the background color using an xterm control sequence.

Many, but not all, terminals support this query. So as a fallback we query environment variable COLORFGBG and failing this we use some defaults for some known terminals set from the TERM environment variable. OSX has its own way of querying characteristics so we use that too if you are running on that OS.

When we can get pixel intensities of red, blue, and green values of the background, we can use that determine light and dark based the combined sum: zero values indicate an absense of a particular color and compare that with the values of the foreground.

You can set any of these environment variables to influence the output decision.

Many thanks to Thomas Dickey, Egmont Koblinger, and Gilles, for explanations (and code!) via unix.stackexchange. John Green had the idea to compare the foreground and background colors instead comparing the background against the midway gray color and implemented that change here.

Of course bugs and lacuna in this code are mine.

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].