From 18cc077a9b0e185b769965b6441762c960a6db0f Mon Sep 17 00:00:00 2001 From: Gabe Venberg Date: Mon, 6 Aug 2018 17:43:12 -0500 Subject: [PATCH] Squashed 'zsh/.zsh/tty-solarized/' content from commit a435d9b git-subtree-dir: zsh/.zsh/tty-solarized git-subtree-split: a435d9b4f7aaa9e0dd0494c504fc1fe3c6a22eee --- README.md | 15 ++++++++++++++ pty2tty.awk | 44 ++++++++++++++++++++++++++++++++++++++++++ tty-solarized-dark.sh | 25 ++++++++++++++++++++++++ tty-solarized-light.sh | 25 ++++++++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 README.md create mode 100755 pty2tty.awk create mode 100644 tty-solarized-dark.sh create mode 100644 tty-solarized-light.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..3422293 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Solarized color theme for the linux TTY + +A tty solarized theme using Ethan Schoonover’s [Solarized color theme](http://ethanschoonover.com/solarized). + +If you are looking for colors on your xterm, konsole, terminator, urxvt, guake, aterm and friends, please search a bit more. This script is for setting the colors on a linux TTY, the real terminal that you get if you are not running ``X`` or ``wayland``. + +## Repositories + * This theme as a single repository: [tty-solarized](https://github.com/joepvd/tty-solarized) + * The main solarized repository: [solarized](https://github.com/altercation/solarized) + +## Installation +Source either ``tty-solarized-dark.sh`` or ``tty-solarized-light.sh`` in the startup file of your shell. As this is only run on TTYs where usually a login shell is started, the login file of your shell (``${ZDOTDIR:-$HOME}/.zlogin`` for zsh or ``~/.profile`` for bash). Now the 'normal' names for colors are available to your applications. + +Included is also the awk-script used to generate those two files. Would the color scheme be changed upstream, anyone with gawk installed can update these files. + diff --git a/pty2tty.awk b/pty2tty.awk new file mode 100755 index 0000000..a6cd837 --- /dev/null +++ b/pty2tty.awk @@ -0,0 +1,44 @@ +#!/usr/bin/gawk -f +# pty2tty.awk: Create solarized color scheme for TTY. +# Usage: ./pty2tty.awk [-v t=light|dark] $Xresources +# With $Xresources from http://github.com/altercation. +# Put resulting code in your shell's startup/login file. +# By Joep van Delft, 2013 + +BEGIN { + if (t~/^[lL]+/) theme="light" + else theme="dark" +} + +/! (Common|Dark|Light) *$/ { + flag=tolower($2) + next +} + +/^(! |)#define/ { + if (flag=="common" || flag==theme) { + solar[$(NF-1)]["var"] = gensub(/[^[:xdigit:]]/,"","g",$NF) + } + next +} + +/^\*color/ { + solar[$2]["code"] = gensub(/[^[:digit:]]+/,"","g",$1) + next +} + +END{ + print "# Solarized theme for tty, the", theme, "version." + print "# Based on:" + print "# - Solarized (http://ethanschoonover.com/solarized)" + print "# - Xresources from http://github.com/altercation/solarized" + print "# Generated with pty2tty.awk by Joep van Delft" + print "# http://github.com/joepvd/tty-solarized" + print "if [ \"$TERM\" = \"linux\" ]; then" + for (desc in solar) + printf " echo -en \"\\e]P%X%s\" # %s\n", \ + solar[desc]["code"], \ + solar[desc]["var"], \ + desc + print " clear # against bg artifacts\nfi" +} diff --git a/tty-solarized-dark.sh b/tty-solarized-dark.sh new file mode 100644 index 0000000..98826e9 --- /dev/null +++ b/tty-solarized-dark.sh @@ -0,0 +1,25 @@ +# Solarized theme for tty, the dark version. +# Based on: +# - Solarized (http://ethanschoonover.com/solarized) +# - Xresources from http://github.com/altercation/solarized +# Generated with pty2tty.awk by Joep van Delft +# http://github.com/joepvd/tty-solarized +if [ "$TERM" = "linux" ]; then + echo -en "\e]PB657b83" # S_base00 + echo -en "\e]PA586e75" # S_base01 + echo -en "\e]P0073642" # S_base02 + echo -en "\e]P62aa198" # S_cyan + echo -en "\e]P8002b36" # S_base03 + echo -en "\e]P2859900" # S_green + echo -en "\e]P5d33682" # S_magenta + echo -en "\e]P1dc322f" # S_red + echo -en "\e]PC839496" # S_base0 + echo -en "\e]PE93a1a1" # S_base1 + echo -en "\e]P9cb4b16" # S_orange + echo -en "\e]P7eee8d5" # S_base2 + echo -en "\e]P4268bd2" # S_blue + echo -en "\e]P3b58900" # S_yellow + echo -en "\e]PFfdf6e3" # S_base3 + echo -en "\e]PD6c71c4" # S_violet + clear # against bg artifacts +fi diff --git a/tty-solarized-light.sh b/tty-solarized-light.sh new file mode 100644 index 0000000..37b75b5 --- /dev/null +++ b/tty-solarized-light.sh @@ -0,0 +1,25 @@ +# Solarized theme for tty, the light version. +# Based on: +# - Solarized (http://ethanschoonover.com/solarized) +# - Xresources from http://github.com/altercation/solarized +# Generated with pty2tty.awk by Joep van Delft +# http://github.com/joepvd/tty-solarized +if [ "$TERM" = "linux" ]; then + echo -en "\e]PB839496" # S_base00 + echo -en "\e]PA93a1a1" # S_base01 + echo -en "\e]P0eee8d5" # S_base02 + echo -en "\e]P62aa198" # S_cyan + echo -en "\e]P8fdf6e3" # S_base03 + echo -en "\e]P2859900" # S_green + echo -en "\e]P5d33682" # S_magenta + echo -en "\e]P1dc322f" # S_red + echo -en "\e]PC657b83" # S_base0 + echo -en "\e]PE586e75" # S_base1 + echo -en "\e]P9cb4b16" # S_orange + echo -en "\e]P7073642" # S_base2 + echo -en "\e]P4268bd2" # S_blue + echo -en "\e]P3b58900" # S_yellow + echo -en "\e]PF002b36" # S_base3 + echo -en "\e]PD6c71c4" # S_violet + clear # against bg artifacts +fi