Git Product home page Git Product logo

tinted-shell's Introduction

Tinted Shell

Matrix Chat

A shell script to change your shell's default ANSI colors. This includes 256 color support if your terminal supports it. This script makes it possible to honor the original bright colors of your shell. The ANSI colors are mapped correctly. (e.g. green is still green). Tinted Shell also provides additional colors to applications such as Vim and tmux.

Have a look at our [Base16 Gallery] to see the various themes supported by Tinted Shell. For more information about Base16 or Base24, have a look at the Tinted Theming Home repository.

Shell image

Use Cases for using a script to theme your shell

  • Portability Across Different Terminal Emulators and SSH sessions.
  • Integration with shell prompts and CLI tools.
  • Compatibility with Text-Based Applications and Scripts.

Usage

Clone the repo locally and execute the script with your posix compliant shell (sh, bash, zsh, etc).

cd path/to/cloned/repo/tinted-shell
sh ./scripts/base16-mocha.sh

Theme managers

This repository has a profile_helper shell script which it has used to "manage" theme switching for a long time. It's evolved to include "hook" scripts which allow users to change other base16 template themes when a theme is set.

It has grown a lot and we decided to build a more robust theming manager tool, written in Rust, called Tinty. At first we were unsure whether it was going to be part of this repository or not, but since it wasn't directory related to tinted-shell (much like profile_helper isn't very related) we decided to move it to its own repository.

With Tinty you can switch your shell theme, or any other base16, base24 or Tinted Theming theme, by running a single command, eg: tinty apply base16-mocha. Read more about it on the Tinty repository.

While we aren't removing the profile_helper, it isn't going to be actively grown anymore since that effort is going into Tinty. But, you can use the Profile Helper shell script. You can read more about it in USAGE.md.

Customization

There are times when templates don't exist for command line applications, or perhaps you just want to play around with colors yourself. You can access these colors by having them set as environment variables.

Base16

Add export TINTED_SHELL_ENABLE_BASE16_VARS=1 to your .*rc file and make sure the variable is set before running the theme script to enable this feature.

This feature enables env vars BASE16_COLOR_01_HEX to BASE16_COLOR_0F_HEX. Have a look at the [Base16 Styling Guidelines] for more styling information.

Base24

Add export TINTED_SHELL_ENABLE_BASE24_VARS=1 to your .*rc file and make sure the variable is set before running the theme script to enable this feature.

This feature enables env vars BASE24_COLOR_01_HEX to BASE24_COLOR_0F_HEX. Have a look at the [Base24 Styling Guidelines] for more styling information.

This feature enables env vars BASE16_COLOR_01_HEX to BASE16_COLOR_0F_HEX.

Troubleshooting

Run the included colortest script and check that your colour assignments appear correct. If your teminal does not support the setting of colours in within the 256 colorspace (e.g. Apple Terminal), colours 17 to 21 will appear blue.

setting 256 colourspace not supported

If colortest is run without any arguments e.g. ./colortest the hex values shown will correspond to the currently set theme. If you'd like to see the hex values for a particular scheme pass the file name of the theme name as the arguement e.g. ./colortest base16-mocha.

Contributing

See CONTRIBUTING.md, which contains building and contributing instructions.

tinted-shell's People

Contributors

chriskempson avatar jamygolden avatar tinted-theming-bot avatar johnmorales avatar fnune avatar vifo avatar danielrs avatar joshbode avatar klebercode avatar bezhermoso avatar nawetimebomb avatar tylerball avatar jdrouhard avatar bashton-ajenkins avatar acidghost avatar andrew-ko avatar nvllsvm avatar iandrewt avatar bradbishop avatar christophgockel avatar dsapala avatar blueyed avatar diegs avatar welcome-linja avatar ghprince avatar hashbang173 avatar howardburgess avatar vassilevsky avatar julio-b avatar belak avatar

Stargazers

Daejung Kim avatar Vera Rei avatar Adam Lindsay avatar Cristian Tentella avatar  avatar Iain Simmons avatar  avatar hunty avatar Chris Hart avatar Legitimate User avatar Seven avatar  avatar Yalçın Açıkyıldız avatar  avatar Erik Kinnunen avatar Johnny Amos avatar Emil Vågstedt avatar  avatar András Jáky avatar Evan Hatch avatar Steve Simkins avatar Tiago avatar Mark Kogan avatar Andy Gorman avatar  avatar  avatar Nandor Biro avatar Andreas Zeidler avatar Jaeyeong Huh avatar 那思路(なしろ) avatar Sylvain Mora avatar adam kaminski avatar Mattia Setzu avatar Aaron avatar Lucas avatar Steven Moazami avatar Rikus Honey avatar hl98 avatar Raul Bonifacio avatar eg avatar Eyad Sibai avatar Felix Heinrichs avatar Адитя avatar Emmanuel Delgado avatar Jon Leopard avatar  avatar  avatar Arseniy Chekanov avatar Elliot Rampono avatar Talal Alobaid avatar jgb avatar Andrew Johnson avatar Otavio Salvador avatar Brendan Timmons avatar

Watchers

 avatar Matt Davis avatar  avatar Aaron avatar

tinted-shell's Issues

PSA: "Why my base16 theme doesn't get applied in tmux anymore?"

Because tmux 3.3a ships with option allow-passthrough set to false by default now. Yup, I have no clue what that means, not that well versed on terminal emulation or ANSI escape sequences. Also it prefers to set TERM variable to tmux-256color as opposed to screen-256color now, so it may or may not mess up your other terminal applications dependent on this variable.

To get your stuff operable you would fancy to add these two lines in your tmux.conf:

set -g allow-passthrough on
# if having issues with your other programs dependent on TERM env variable
set -g default-terminal screen-256color

tmux 3.3a discussions: tmux/tmux#3218

Hope it was worth the read.

profile_helper.sh sets the theme when it is sourced even if the theme did not change

Describe the bug

Using the recommended .zshrc configuration:

# Base16 Shell
BASE16_SHELL_PATH="$HOME/.config/base16-shell"
[ -n "$PS1" ] && \
  [ -s "$BASE16_SHELL_PATH/profile_helper.sh" ] && \
    source "$BASE16_SHELL_PATH/profile_helper.sh"

But every time profile_helper.sh sourced via .zshrc, it resets the theme. Meaning, it recreates the theme soft link and executes the hooks.
One of my tools (waybar) refreshes itself when the underlying (hook) link is recreated. This means whevener a terminal is opened, the tool resets with a flicker. A bit annoying.

Expected behavior

No need to create the soft links and executing hooks when the theme did not change.

System

Operating system:
archlinux

Terminal:
foot with zsh

Base16 tool
waybar

Additional context

I've put this little hack in set_theme function in profile_helper.sh just before the soft link creation:

  # Does the symlink already exists with the same target?
  if [ "`readlink $BASE16_SHELL_COLORSCHEME_PATH`" -ef "$script_path" ]; then
      return 0 # then no need to do recreate the link and execute the hooks
  fi

[Bug report] Git delta hook unknown option and light value issues

Describe the bug

@bezhermoso I've noticed 2 issues with the new git delta hook:

  • The -g option doesn't exist for me
  • The is_light_theme variable has either the values 0 or 01 which causes the light value to give an error: (eval):9: command not found: 01

Screenshots

These screenshots are with the removal of the -g option for bc command on line 19.

Works correctly when setting a dark theme
image

Does not work correctly when setting a light theme (notice # is_light_theme = 01 on line 18)
image

System

Operating system: Pop!Os (Linux)

Terminal: Alacritty

NCurses programs break colors

Describe the bug

Using an ncurses based program, such as tig or ranger, will break the colors when you return to your normal terminal. Colors can be restored by running the appropriate base16- command again

Expected behavior

The colors should not break when exiting an ncurses app

System

Operating system:
MacOS 12.6

Terminal:

  • iTerm2 Build 3.5.0beta8
  • xterm-256color
  • fish-shell
  • tomorrow-night theme

Additional context

This does not happen if the TERM is set to something like xterm-new

Does not create base16-tmux config file in fish shell

Describe the bug

When running in fish shell, base16-shell does not create the config file required for base16-tmux to switch colours. This bug occurs when $XDG_CONFIG_HOME is set.

It looks like a typo was introduced in #22. The hook is setting $BASE16_HEXCHAT_PATH instead of $BASE16_TMUX_PLUGIN_PATH:

https://github.com/tinted-theming/base16-shell/blob/a4267892b33505e009df7b386693f594dffde716/hooks/base16-tmux.fish#L15-L21

Expected behavior

The base16-shell hook $BASE16_SHELL_HOOKS_PATH/base16-tmux.fish should create $BASE16_CONFIG_PATH/tmux.base16.conf each time the theme is changed. This is picked up by base16-tmux to change the tmux colour definitions.

Screenshots

System

Operating system:
Noticed on macOS Sonoma 14.0 M1 (and tested in a Fedora Docker container).

$ uname -a
Darwin lumen-10.local 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:34 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T8103 arm64

Terminal:
Alacritty 0.12.3 (1)

Minimal configuration file

How to reproduce in Docker

Uncompress base16-fish-bug.tar.gz, which contains Fedora with fish shell and minimal installations of base16-shell and base16-tmux.

Expand to see files

Dockerfile.fish

FROM fedora:38

ENV HOME /root
# Bug appears when XDG_CONFIG_HOME is set explicitly
ENV XDG_CONFIG_HOME $HOME/.config

RUN dnf update -y
RUN dnf install -y git

# tmux + TPM
RUN dnf install -y tmux
COPY tmux.conf $HOME/.config/tmux/
RUN git clone https://github.com/tmux-plugins/tpm $XDG_CONFIG_HOME/tmux/plugins/tpm
RUN TMUX_PLUGIN_MANAGER_PATH=$XDG_CONFIG_HOME/tmux/plugins $XDG_CONFIG_HOME/tmux/plugins/tpm/bin/install_plugins

# fish shell
RUN dnf install -y fish util-linux-user
COPY config.fish $HOME/.config/fish/
RUN chsh -s /usr/bin/fish

# base16-shell
RUN git clone https://github.com/tinted-theming/base16-shell.git $HOME/.config/base16-shell
# Uncomment to illustrate the fix
#RUN sed -i 's/HEXCHAT/TMUX_PLUGIN/' $HOME/.config/base16-shell/hooks/base16-tmux.fish

ENTRYPOINT ["fish"]

config.fish

# Base16 Shell
if status --is-interactive
  set BASE16_SHELL_PATH "$HOME/.config/base16-shell"
  if test -s "$BASE16_SHELL_PATH"
    source "$BASE16_SHELL_PATH/profile_helper.fish"
  end
end

tmux.conf

set-option -g @plugin 'tmux-plugins/tpm'
set-option -g @plugin 'tinted-theming/base16-tmux'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'

set -g @colors-base16 'default-dark'
source-file $HOME/.config/tinted-theming/tmux.base16.conf

Demonstrate the bug

Show that base16-tmux.fish is not created when setting a theme:

$ docker build -f Dockerfile.fish -t fish .

$ docker run --rm -it fish --interactive --command 'ls -l ~/.config/tinted-theming; base16-eighties; ls -l ~/.config/tinted-theming'
total 0
-rw-r--r-- 1 root root 0 Oct 14 11:57 theme_name
total 12
lrwxrwxrwx 1 root root  53 Oct 14 11:57 base16_shell_theme -> /root/.config/base16-shell/scripts/base16-eighties.sh
-rw-r--r-- 1 root root 187 Oct 14 11:57 set_theme.lua
-rw-r--r-- 1 root root 102 Oct 14 11:57 set_theme.vim
-rw-r--r-- 1 root root   9 Oct 14 11:57 theme_name

Demonstrate a fix

Uncomment the following line in Dockerfile.fish:

# Uncomment to illustrate the fix
#RUN sed -i 's/HEXCHAT/TMUX_PLUGIN/' $HOME/.config/base16-shell/hooks/base16-tmux.fish

Then rebuild the Docker image and run. The tmux.base16.conf file is created when switching theme.

docker run --rm -it fish --interactive --command 'ls -l ~/.config/tinted-theming; base16-eighties; ls -l ~/.config/tinted-theming'
total 0
-rw-r--r-- 1 root root 0 Oct 14 12:04 theme_name
total 16
lrwxrwxrwx 1 root root  53 Oct 14 12:04 base16_shell_theme -> /root/.config/base16-shell/scripts/base16-eighties.sh
-rw-r--r-- 1 root root 187 Oct 14 12:04 set_theme.lua
-rw-r--r-- 1 root root 102 Oct 14 12:04 set_theme.vim
-rw-r--r-- 1 root root   9 Oct 14 12:04 theme_name
-rw-r--r-- 1 root root  33 Oct 14 12:04 tmux.base16.conf

Additional context

[Bug report] color test doesn't respect $BASE16_THEME

Describe the bug

The color test script doesn't use the existing theme and reverts to default

Expected behavior

colortest should use the theme set by the user instead of changing it to the default dark theme

System

Operating system: MacOS Sonoma 14.2

Terminal: iTerm2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.