An open API service indexing awesome lists of open source software.

https://github.com/dyuri/xontrib-termcolors

Set terminal colors based on selected xonsh theme.
https://github.com/dyuri/xontrib-termcolors

xonsh xontrib

Last synced: 5 months ago
JSON representation

Set terminal colors based on selected xonsh theme.

Awesome Lists containing this project

README

        


Set terminal colors based on selected xonsh theme.


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

## Installation

To install use pip:

```bash
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.

```bash
$ xontrib load termcolors
```

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

```bash
$ $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`:
```python
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](https://github.com/xonsh/xontrib-cookiecutter).