Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and 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

base16 color test #2

Open
pvinis opened this issue Nov 1, 2018 · 0 comments
Open

base16 color test #2

pvinis opened this issue Nov 1, 2018 · 0 comments
Assignees

Comments

@pvinis
Copy link
Owner

pvinis commented Nov 1, 2018

add this one

#!/usr/bin/env bash
theme=$(dirname $0)/scripts/${1:-base16-default-dark.sh}
if [ -f $theme ]; then
  # get the color declarations in said theme, assumes there is a block of text that starts with color00= and ends with new line
  eval $(awk '/^color00=/,/^$/ {print}' $theme | sed 's/#.*//')
else
  printf "No theme file %s found\n" $theme
fi;
ansi_mappings=(
  Black
  Red
  Green
  Yellow
  Blue
  Magenta
  Cyan
  White
  Bright_Black
  Bright_Red
  Bright_Green
  Bright_Yellow
  Bright_Blue
  Bright_Magenta
  Bright_Cyan
  Bright_White
)
colors=(
  base00
  base08
  base0B
  base0A
  base0D
  base0E
  base0C
  base05
  base03
  base08
  base0B
  base0A
  base0D
  base0E
  base0C
  base07
  base09
  base0F
  base01
  base02
  base04
  base06
)
for padded_value in `seq -w 0 21`; do
  color_variable="color${padded_value}"
  eval current_color=\$${color_variable}
  current_color=$(echo ${current_color//\//} | tr '[:lower:]' '[:upper:]') # get rid of slashes, and uppercase
  non_padded_value=$((10#$padded_value))
  base16_color_name=${colors[$non_padded_value]}
  current_color_label=${current_color:-unknown}
  ansi_label=${ansi_mappings[$non_padded_value]}
  block=$(printf "\x1b[48;5;${non_padded_value}m___________________________")
  foreground=$(printf "\x1b[38;5;${non_padded_value}m$color_variable")
  printf "%s %s %s %-30s %s\x1b[0m\n" $foreground $base16_color_name $current_color_label ${ansi_label:-""} $block
done;
@pvinis pvinis self-assigned this Nov 1, 2018
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

1 participant