Skip to main content

Set terminal colors based on selected xonsh theme.

If you like the idea click ⭐ on the repo and tweet.

Installation

To install use pip:

xpip install xontrib-termcolors
# or: xpip install -U git+https://github.com/dyuri/xontrib-termcolors

Usage

This xontrib sets the colors of your (xterm compatible) terminal based on your xonsh theme.

$ xontrib load termcolors

If you change your theme and want to update the terminal colors use the termcolors command:

$ $XONSH_COLOR_STYLE="monokai"
$ termcolors

Colors

The main 16 colors will be used directly from the pygments/ptk theme. The following special colors can be set by adding the tokens to your theme:

  • Token.Terminal.Foreground - foreground color
  • Token.Terminal.Background - background color
  • Token.Terminal.Curson - cursor color

Example

To replace all colors in xonsh and terminal to green add this to your .xonshrc:

from xonsh.tools import register_custom_style
from xonsh import style_tools
from pygments.token import Token

mystyle = {k: '#00ff00' for k,c in style_tools.DEFAULT_STYLE_DICT.items()}
mystyle[Token.Terminal.Foreground] = '#00ff00'
mystyle[Token.Terminal.Curson] = '#00ff00'
mystyle[Token.Terminal.Background] = '#000000'

register_custom_style("green", mystyle, base=__xonsh__.env['XONSH_COLOR_STYLE'])
$XONSH_COLOR_STYLE="green"

xontrib load termcolors

Credits

This package was created with xontrib cookiecutter template.

Metadata

Release files for xontrib-termcolors 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xontrib-termcolors 0.2.0
File Size Uploaded
xontrib-termcolors-0.2.0.tar.gz 3.9 kB Details

Release files / xontrib-termcolors-0.2.0.tar.gz

Download URL xontrib-termcolors-0.2.0.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
65a56eaef1db1c5af47ef21cfcc78156a89816d71b5dc465e351b3808dba708c
BLAKE2b-256 checksum
How to use checksums
3fa3bf80d46777a74e9404f7ed84c771256e397af12f88ecefe8983861371a43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page