8000 terminal color switching using base16 · Issue #70 · wincent/wincent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

terminal color switching using base16 #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and 8000 the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
damnskippy opened this issue Dec 21, 2018 · 4 comments
Closed

terminal color switching using base16 #70

damnskippy opened this issue Dec 21, 2018 · 4 comments

Comments

@damnskippy
Copy link

This is more of a question (than an issue) regarding usage of color function to change the terminal base16-shell color theme, in a TMUX session with multiple windows.
(BTW, this whole idea behind the dark/light determination and dynamic switching is stupendous!).

When the terminal theme is switched by doing a color <theme>, if the TMUX session has multiple tmux "windows", the color change seems to take effect only in the current/active window, other tmux windows continue with the old/previous theme. I think this behavior makes sense as this seems to be achieved by sending esacpe sequences to the terminal. (FWIW I'm using gnome-terminal on linux (ubuntu).)

My question is do you also see the same behavior? Or am I missing a trick somewhere to change other tmux windows as well? Or it's possible I'm doing something wrong in my conf files somewhere to cause this for myself. So I just thought I'd check with you just in case.

(I guess I could do a list-windows/panes for the session and do a send-keys of the color command, but I'm a bit wary about typing keys somewhat arbitrarily into a pane. Maybe I could open a new temporary pane and run this command and close the pane when done..)

Thank you.

@wincent
Copy link
Owner
wincent commented Dec 21, 2018

Yep. This is expected. I considered it an acceptable compromise because I switch colors rarely. But I do think it would be worth at least making color without arguments (re)apply the current scheme instead of just reporting it. That way you could at least force a refresh pretty straightforwardly without having to remember or type the name of the scheme.

@damnskippy
Copy link
Author

Thanks. FWIW, I wrote up this shell util to that does it. Just about the only thing worked. Doing anything else to be less "intrusive" never set the colors correctly.

#!/bin/sh
multiple_windows=$(tmux display-message -p '#{session_windows}')
if [ "$multiple_windows" -gt 1 ]; then
    CONF=~/.vim/.base16
    if [ -f $CONF ]; then
        theme=$(sed '1q;d' $CONF)
    else
        return 1
    fi
    pane_origin=$(tmux display-message -p '#I.#P')
    for w in `tmux list-panes -s -F '#I.#P' | uniq -w1`
    do
        tmux split-window -t $w -l 2
        sleep 0.1 # without this pause, sometimes switching fails
        tmux send-keys "color $theme" C-m
        tmux send-keys "exit" C-m
    done
    tmux select-window -t $pane_origin
fi

Alternatively, I also added this to the colors file. However the fact that this file is sourced every time a shell is spawned meant I needed this flag SOURCING_NEW_SHELL which gets set at the top of the file and reset at the end of the file. This way this logic only gets invoked when color is called to explicitly set a theme.

BASE16_CONFIG=~/.vim/.base16
SOURCING_NEW_SHELL=1
[...]
        multiple_windows=$(tmux display-message -p '#{session_windows}')
        if [ $SOURCING_NEW_SHELL -eq 0 -a $multiple_windows -gt 1 ]; then
            pane_origin=$(tmux display-message -p '#I.#P')
            for w in `tmux list-panes -s -F '#I.#P' | uniq -w1`
            do
                tmux split-window -t $w -l 2
                sleep 0.1 # without this pause, sometimes switching fails
                # tmux send-keys "color $" C-m
                tmux send-keys "sh $FILE" C-m
                tmux send-keys "exit" C-m
            done
            # go back to where we started
            tmux select-window -t $pane_origin
        fi
[...]
SOURCING_NEW_SHELL=0

On a related note, personally I'm not sure color needs to be set (determining background, luma, source theme, saving config), every time a shell is spawned when this file gets sourced. Commenting out the anonymous function() at the end of this file to avoid this seemed to speed up the spawning of the shell a bit. I do understand the need to set the theme automatically based on the config first time a shell is spawned in the terminal, although I'm not sure how I would determine that programmatically.

@damnskippy
Copy link
Author
damnskippy commented Dec 21, 2018

One other thing I failed to note is that I also used this wonderful logic as a hook to set the theme for FZF as well using:
https://github.com/nicodebo/base16-fzf

Basically added the following after sh $FILE
source ~/.zsh/base16-fzf/bash/base16-$SCHEME.config

Thanks very much for all of this.

@damnskippy
Copy link
Author

set the theme automatically based on the config first time a shell is spawned in the terminal, although I'm not sure how I would determine that programmatically.

I guess one way to do when running TMUX would be to check for something like this perhaps in colors file.

    if [ $(tmux display-message -p '#{session_windows}') -eq 1 -a \
        $(tmux display-message -p '#{window_panes}') -eq 1 ]; then
        [...]
    fi

Just a thought.

wincent added a commit that referenced this issue Dec 24, 2018
As noted here:

#70

If you change colors in another terminal window (but not a tmux window)
it won't get picked up. Make it easy to pick it up just by running
`color` without args. Not implementing the fully automatic solution
discussed in that issue because I don't tend to change colors that often
so I don't think I need it. If I did it, however, I'd probably look at
using a Zsh precmd hook.
wincent added a commit that referenced this issue Jul 11, 2022
Upstream deleted the `master` branch, replacing it with `main`:

    Fetching origin
    From https://github.com/chriskempson/base16-schemes-source
     - [deleted]         (none)     -> origin/master
       (refs/remotes/origin/HEAD has become dangling)
    remote: Enumerating objects: 16, done.
    remote: Counting objects: 100% (16/16), done.
    remote: Compressing objects: 100% (16/16), done.
    remote: Total 16 (delta 4), reused 0 (delta 0), pack-reused 0
    Unpacking objects: 100% (16/16), 6.91 KiB | 372.00 KiB/s, done.
     * [new branch]      main       -> origin/main

Remarkably, current `HEAD` of `main` isn't even a descendant of The
Branch Formerly known as `master`:

* vendor/base16-schemes-source e720724...944dbc7 (88):
  > Update list.yaml
  > Update README.md
  > Update list.yaml
  > Update README.md
  > Add files via upload
  < Add Sakura scheme (#73)
  < Add pinky scheme
  < Add Shades of Purple scheme (#75)
  < Add qualia to list.yaml
  < Merge pull request #79 from CosmosAtlas/patch-1
  < Add windows theme (#83)
  < Merge pull request #84 from casonadams/master
  < Merge pull request #85 from edunfelt/master
  < Merge pull request #66 from DanManN/master
  < Merge pull request #77 from akhsiM/master
  < Merge pull request #80 from Misterio77/patch-2
  < Merge pull request #81 from cveldy/master
  < Add Nebula scheme (#70)
  < Add "colors" color scheme (#68)
  < Add Pasque color scheme (#69)
  < Add vice scheme (#65)
  < Merge pull request #64 from kjakapat/master
  < Added darkmoss scheme (#55)
  < Merge pull request #63 from andreyvpng/master
  < Merge pull request #60 from tartansandal/tartansandal-add-dirtysea-scheme
  < Update list.yaml
  < Merge pull request #58 from jpfender/nord-fix
  < Re-enable summercamp
  < Merge pull request #53 from carloabelli/equilibrium-scheme
  < Merge pull request #62 from humanoid-colors/humanoid
  < Merge pull request #61 from ruler501/patch-1
  < Merge pull request #59 from Schnouki/patch-1
  < Merge pull request #56 from callerc1/master
  < Merge pull request #54 from cjayross/master
  < Merge pull request #52 from Whillikers/master
  < Re-add sandcastle and nova
  < Merge pull request #51 from alexmirrington/master
  < Merge pull request #50 from jssee/framer-scheme
  < Merge pull request #49 from base16-project/master
  < Merge pull request #42 from ajlende/patch-2
  < Merge pull request #41 from tealeg/patch-1
  < Merge pull request #40 from archmalet/master
  < Merge pull request #39 from jonleopard/master
  < Merge pull request #38 from jozip/master
  < Merge pull request #36 from aramisgithub/patch-3
  < Merge pull request #35 from h404bi/patch-1
  < Merge pull request #34 from metalelf0/master
  < Merge pull request #33 from aramisgithub/patch-1
  < Merge pull request #32 from piggyslasher/patch-1
  < Merge pull request #31 from joshyrobot/patch-1
  < Merge pull request #30 from mnussbaum/solarflare
  < Merge pull request #29 from hugodelahousse/patch-1
  < Merge pull request #28 from blockloop/patch-1
  < Merge pull request #27 from icyphox/master
  < Update README.md
  < Merge pull request #26 from AuditeMarlow/add-porple-scheme
  < Merge pull request #25 from gonsie/master
  < Merge pull request #24 from gidsi/master
  < Merge pull request #23 from mikebarkmin/patch-1
  < Merge pull request #22 from WhiteAbeLincoln/patch-1
  < Update list.yaml
  < Merge pull request #21 from ntpeters/patch-1
  < Merge pull request #19 from elnawe/master
  < Merge pull request #18 from Pokeconomist/patch-1
  < Merge pull request #14 from detly/master
  < Merge pull request #17 from purpleKarrot/master
  < Merge pull request #15 from Defman21/patch-3
  < Merge pull request #16 from stepchowfun/add-circus
  < Merge pull request #13 from 8-uh/patch-1
  < Merge pull request #12 from vic/patch-1
  < Merge pull request #11 from dawikur/master
  < Update README.md
  < Update list.yaml
  < Merge pull request #10 from jcornwall/master
  < Merge pull request #9 from mikebarkmin/patch-1
  < Merge pull request #8 from tilal6991/master
  < Merge branch 'joshwlewis-patch-1't push origin master
  < Merge branch 'cscorlt push origin masterey-patch-1'
  < t push origin masterMerge branch 'hartbit-master'
  < Merge pull request #4 from Defman21/patch-2
  < Merge pull request #3 from drzel/master
  < Merge branch 'refs/heads/pr/2'
  < Merge pull request #1 from atelierbram/atelier
  < Adds unclaimed schemes
  < Create README.md
  < Initial commit
  < Revert ":octocat: Added .gitattributes"
  < :octocat: Added .gitattributes

So here is a diff (via `cd vendor/base16-schemes-source && git diff
e720724..944dbc7`) for posterity:

```diff
diff --git a/README.md b/README.md
index c8feea9..28e0932 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,82 @@
 # Base16 Schemes Source
 By adding your repository to this list your scheme will be available to all Base16 Builders.
 All schemes added to this repository list **must** be released under the MIT (or more permissive) licence.
-Please list your scheme under https://github.com/chriskempson/base16#scheme-repositories so that others may find it easily.
+
+## Scheme Repositories
+
+To add your own scheme, submit a pull request and add your repository to the list below. **Repository naming scheme: base16-[scheme-name]-scheme** (with dashes as separators).
+
+### Official Schemes
+* [Default](https://github.com/chriskempson/base16-default-scheme) maintained by [chriskempson](https://github.com/chriskempson)
+
+### Community Contributed Schemes
+* [Apprentice](https://github.com/casonadams/base16-apprentice-scheme) maintained by [casonadams](https://github.com/casonadams)
+* [Atelier](https://github.com/atelierbram/base16-atelier-schemes) maintained by [atelierbram](https://github.com/atelierbram)
+* [Atlas](https://github.com/ajlende/base16-atlas-scheme) maintained by [ajlende](https://github.com/ajlende)
+* [Black Metal](https://github.com/metalelf0/base16-black-metal-scheme) maintained by [metalelf0](https://github.com/metalelf0)
+* [Brogrammer](https://github.com/piggyslasher/base16-brogrammer-scheme) maintained by [piggyslasher](https://github.com/piggyslasher)
+* [Brush Trees](https://github.com/whiteabelincoln/base16-brushtrees-scheme) maintained by [whiteabelincoln](https://github.com/whiteabelincoln)
+* [Circus](https://github.com/stepchowfun/base16-circus-scheme) maintained by [stepchowfun](https://github.com/stepchowfun) and [ewang12](https://github.com/ewang12)
+* [Classic](https://github.com/detly/base16-classic-scheme) maintained by [detly](https://github.com/detly)
+* [Codeschool](https://github.com/blockloop/base16-codeschool-scheme) maintained by [blockloop](https://github.com/blockloop)
+* [Colors](https://github.com/hakatashi/base16-colors-scheme) maintained by [hakatashi](https://github.com/hakatashi)
+* [Cupertino](https://github.com/Defman21/base16-cupertino) maintained by [Defman21](https://github.com/Defman21)
+* [DanQing](https://github.com/CosmosAtlas/base16-danqing-scheme) maintained by [CosmoAtlas](https://github.com/CosmosAtlas)
+* [Darcula](https://github.com/casonadams/base16-darcula-scheme) maintained by [casonadams](https://github.com/casonadams)
+* [Darkviolet](https://github.com/ruler501/base16-darkviolet-scheme) maintained by [ruler501](https://github.com/ruler501)
+* [Dracula](https://github.com/dracula/base16-dracula-scheme) maintained by [mikebarkmin](https://github.com/mikebarkmin)
+* [Equilibrium](https://github.com/carloabelli/base16-equilibrium-scheme) maintained by [carloabelli](https://github.com/carloabelli)
+* [Espresso](https://github.com/alexmirrington/base16-espresso-scheme) maintained by [alexmirrington](https://github.com/alexmirrington)
+* [Eva](https://github.com/kjakapat/base16-eva-scheme) maintained by [kjakapat](https://github.com/kjakapat)
+* [Framer](https://github.com/jssee/base16-framer-scheme) maintained by [jssee](https://github.com/jssee)
+* [Fruit Soda](https://github.com/jozip/base16-fruit-soda-scheme) maintained by [jozip](https://github.com/jozip)
+* [Gigavolt](https://github.com/Whillikers/base16-gigavolt-scheme) maintained by [Whillikers](https://github.com/Whillikers)
+* [Github](https://github.com/Defman21/base16-github-scheme) maintained by [Defman21](https://github.com/Defman21)
+* [Gruvbox](https://github.com/dawikur/base16-gruvbox-scheme) maintained by [dawikur](https://github.com/dawikur)
+* [Hardcore](https://github.com/callerc1/base16-hardcore-scheme) maintained by [callerc1](https://github.com/callerc1)
+* [Helios](https://github.com/reyemxela/base16-helios-scheme) maintained by [reyemxela](https://github.com/reyemxela)
+* [Heetch](https://github.com/tealeg/base16-heetch-scheme) maintained by [tealeg](https://github.com/tealeg)
+* [Horizon](https://github.com/michael-ball/base16-horizon-scheme) maintained by [michael-ball](https://github.com/michael-ball)
+* [Humanoid](https://github.com/humanoid-colors/base16-humanoid-schemes) maintained by [tasmo](https://github.com/tasmo)
+* [iA](https://github.com/aramisgithub/base16-ia-scheme) maintained by [aramisgithub](https://github.com/aramisgithub)
+* [Icy](https://github.com/icyphox/base16-icy-scheme) maintained by [icyphox](https://github.com/icyphox)
+* [Kimber](https://github.com/akhsiM/base16-kimber-scheme) maintained by [Mishka](https://github.com/akhsiM)
+* [Materia](https://github.com/Defman21/base16-materia) maintained by [Defman21](https://github.com/Defman21)
+* [Material Theme](https://github.com/ntpeters/base16-materialtheme-scheme) maintained by [ntpeters](https://github.com/ntpeters)
+* [Material Vivid](https://github.com/joshyrobot/base16-material-vivid-scheme) maintained by [joshyrobot](https://github.com/joshyrobot)
+* [Mellow](https://github.com/gidsi/base16-mellow-scheme) maintained by [gidsi](https://github.com/gidsi)
+* [Mexico-Light](https://github.com/drzel/base16-mexico-light-scheme) maintained by [drzel](https://github.com/drzel)
+* [Nebula](https://github.com/Misterio77/base16-nebula-scheme) maintained by [Misterio77](https://github.com/Misterio77)
+* [Nord](https://github.com/8-uh/base16-nord-scheme) maintained by [8-uh](https://github.com/8-uh)
+* [Nova](https://github.com/gessig/base16-nova-scheme) maintained by [gessig](https://github.com/gessig)
+* [One Light](https://github.com/purpleKarrot/base16-one-light-scheme) maintained by [purpleKarrot](https://github.com/purpleKarrot)
+* [Onedark](https://github.com/tilal6991/base16-onedark-scheme) maintained by [tilal6991](https://github.com/tilal6991)
+* [Outrun](https://github.com/hugodelahousse/base16-outrun-schemes) maintained by [hugodelahousse](https://github.com/hugodelahousse)
+* [PaperColor](https://github.com/jonleopard/base16-papercolor-scheme) maintained by [jonleopard](https://github.com/jonleopard)
+* [Pasque](https://github.com/Misterio77/base16-pasque-scheme) maintained by [Misterio77](https://github.com/Misterio77)
+* [pinky](https://github.com/b3nj5m1n/base16-pinky-scheme) maintained by [b3nj5m1n](https://github.com/b3nj5m1n)
+* [Porple](https://github.com/AuditeMarlow/base16-porple-scheme) maintained by [AuditeMarlow](https://github.com/AuditeMarlow)
+* [Purpledream](https://github.com/archmalet/base16-purpledream-scheme) maintained by [archmalet](https://github.com/archmalet)
+* [Qualia](https://github.com/isaacwhanson/base16-qualia-scheme) maintained by [isaacwhanson](https://github.com/isaacwhanson)
+* [Rebecca](https://github.com/vic/base16-rebecca) maintained by [vic](https://github.com/vic)
+* [Rosé Pine](https://github.com/edunfelt/base16-rose-pine-scheme) maintained by [edunfelt](https://github.com/edunfelt)
+* [Sagelight](https://github.com/cveldy/base16-sagelight-scheme) maintained by [cveldy](https://github.com/cveldy)
+* [Sakura](https://github.com/Misterio77/base16-sakura-scheme) maintained by [Misterio77](https://github.com/Misterio77)
+* [Sandcastle](https://github.com/gessig/base16-sandcastle-scheme) maintained by [gessig](https://github.com/gessig)
+* [Shades of Purple](https://github.com/ahmadawais/base16-shades-of-purple) maintained by [Ahmad Awais](https://github.com/ahmadawais) and [Demartini](https://github.com/demartini)
+* [Silk](https://github.com/Misterio77/base16-silk-scheme) maintained by [Misterio77](https://github.com/misterio77)
+* [Snazzy](https://github.com/h404bi/base16-snazzy-scheme) maintained by [h404bi](https://github.com/h404bi)
+* [Solarflare](https://github.com/mnussbaum/base16-solarflare-scheme) maintained by [mnussbaum](https://github.com/mnussbaum)
+* [Solarized](https://github.com/aramisgithub/base16-solarized-scheme) maintained by [aramisgithub](https://github.com/aramisgithub)
+* [Summercamp](https://github.com/zoefiri/base16-summercamp) maintained by [zoe firi](https://github.com/zoefiri)
+* [Summerfruit](https://github.com/cscorley/base16-summerfruit-scheme) maintained by [cscorley](https://github.com/cscorley)
+* [Synth Midnight](https://github.com/michael-ball/base16-synth-midnight-scheme) maintained by [michael-ball](https://github.com/michael-ball)
+* [Tender](https://github.com/DanManN/base16-tender-scheme) maintained by [DanManN](https://github.com/DanManN)
+* [Twilight](https://github.com/hartbit/base16-twilight-scheme) maintained by [hartbit](https://github.com/hartbit)
+* [Unikitty](https://github.com/joshwlewis/base16-unikitty) maintained by [joshwlewis](https://github.com/joshwlewis)
+* [Vice](https://github.com/Thomashighbaugh/base16-vice-scheme) maintained by [Thomashighbaugh](https://github.com/Thomashighbaugh)
+* [Windows](https://github.com/C-Fergus/base16-windows-scheme) maintained by [C-Fergus](https://github.com/C-Fergus)
+* [Woodland](https://github.com/jcornwall/base16-woodland-scheme) maintained by [jcornwall](https://github.com/jcornwall)
+* [Zenburn](https://github.com/elnawe/base16-zenburn-scheme) maintained by [elnawe](https://github.com/elnawe)
+* [XCode Dust](https://github.com/gonsie/base16-xcode-dusk-scheme) maintained by [gonsie](https://github.com/gonsie)
+* [Old Unclaimed Schemes](https://github.com/chriskempson/base16-unclaimed-schemes) - If your scheme is in this repository, please give it a new home!
diff --git a/list.yaml b/list.yaml
index d0e6116..6382e24 100644
--- a/list.yaml
+++ b/list.yaml
@@ -1,4 +1,7 @@
-# Please order list alphanumerically
+# Offical Base16 Schemes
+default: https://github.com/chriskempson/base16-default-schemes
+
+# Community Contributed Schemes - Please order list alphanumerically
 apprentice: https://github.com/casonadams/base16-apprentice-scheme
 atelier: https://github.com/atelierbram/base16-atelier-schemes
 atlas: https://github.com/ajlende/base16-atlas-scheme
@@ -14,7 +17,6 @@ darcula: https://github.com/casonadams/base16-darcula-scheme
 darkmoss: https://github.com/avanzzzi/base16-darkmoss-scheme
 darkviolet: https://github.com/ruler501/base16-darkviolet-scheme
 danqing: https://github.com/CosmosAtlas/base16-danqing-scheme
-default: https://github.com/chriskempson/base16-default-schemes
 dirtysea: https://github.com/tartansandal/base16-dirtysea-scheme
 dracula: https://github.com/dracula/base16-dracula-scheme
 edge: https://github.com/cjayross/base16-edge-schemes
@@ -25,6 +27,7 @@ framer: https://github.com/jssee/base16-framer-scheme
 fruit-soda: https://github.com/jozip/base16-fruit-soda-scheme
 gigavolt: https://github.com/Whillikers/base16-gigavolt-scheme
 github: https://github.com/Defman21/base16-github-scheme
+gruber: https://github.com/nimaipatel/base16-gruber
 gruvbox: https://github.com/dawikur/base16-gruvbox-scheme
 hardcore: https://github.com/callerc1/base16-hardcore-scheme
 heetch: https://github.com/tealeg/base16-heetch-scheme
@@ -40,6 +43,7 @@ material-vivid: https://github.com/joshyrobot/base16-material-vivid-scheme
 mellow: https://github.com/gidsi/base16-mellow-scheme
 mexico-light: https://github.com/drzel/base16-mexico-light-scheme
 nebula: https://github.com/Misterio77/base16-nebula-scheme
+nord: https://github.com/spejamchr/base16-nord-scheme
 nova: https://github.com/gessig/base16-nova-scheme
 onedark: https://github.com/tilal6991/base16-onedark-scheme
 one-light: https://github.com/purpleKarrot/base16-one-light-scheme
@@ -65,7 +69,6 @@ summerfruit: https://github.com/cscorley/base16-summerfruit-scheme
 synth-midnight: https://github.com/michael-ball/base16-synth-midnight-scheme
 tango: https://github.com/Schnouki/base16-tango-scheme
 tender: https://github.com/DanManN/base16-tender-scheme
-tomorrow: https://github.com/chriskempson/base16-tomorrow-scheme
 twilight: https://github.com/hartbit/base16-twilight-scheme
 unikitty: https://github.com/joshwlewis/base16-unikitty
 vice: https://github.com/Thomashighbaugh/base16-vice-scheme
@@ -77,9 +80,3 @@ zenburn: https://github.com/elnawe/base16-zenburn-scheme

 # If your scheme is in this repository, please give it a new home!
 unclaimed: https://github.com/chriskempson/base16-unclaimed-schemes
-
-# NOTE: the original repo at https://github.com/8-uh/base16-nord-scheme
-# is based on another color scheme and doesn't quite match. There was a
-# fork to improve the colors, so that's what we're using. If the original
-# repo ever gets updated, we can switch back to that.
-nord: https://github.com/spejamchr/base16-nord-scheme
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0