From 2d5decf66d243023cae78cab5116a14af797d409 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Sat, 28 Mar 2020 22:06:52 +0100 Subject: [PATCH] Edit "slideshow" script --- Color-schemes.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Color-schemes.md b/Color-schemes.md index 6f27d2d..3ff6b5f 100644 --- a/Color-schemes.md +++ b/Color-schemes.md @@ -44,8 +44,10 @@ alcs0 = $<.each_with_object({y:false, t:[]}) { |l,ah| ah[:y] and l.strip=="```" and (ah[:y]=false;next) ah[:y] and (ah[:t].last||[]) << l }[:t] -alcs1=alcs0.each_with_object({}) {|e,ah| (e[1..-1].grep(/\A\s*[^#]/)[0]||"") =~ /colors:/ and ah[e[0]]=YAML.load(e[1..-1].join)["colors"]} -alcs2={"schemes"=>alcs1,"scheme_toc"=> alcs1.dup} +alcs1 = alcs0.each_with_object({}) { |e,ah| + (e[1..-1].grep(/\A\s*[^#]/)[0]||"") =~ /colors:/ and ah[e[0]]=YAML.load(e[1..-1].join)["colors"] +} +alcs2 = {"schemes"=> alcs1, "scheme_toc"=> alcs1.dup} puts alcs2.to_yaml ``` @@ -76,14 +78,18 @@ Or, saving the output as _alcs.yml_, you can run a "slideshow" of themes as foll ```shell #!/bin/sh - + cnf="$1" tty=`tty` - + ruby -ryaml -e 'puts YAML.load($<)["schemes"].keys' "$cnf" | cat -n | \ while read j s; do echo $j. $s - ruby -ryaml -i -e 'sch=$*.pop; cnf=YAML.load $<; cnf["colors"]=cnf["schemes"][sch]; puts cnf.to_yaml' "$cnf" "$s" + ruby -ryaml -i -e ' + sch=$*.pop + cnf=YAML.load $< + cnf["colors"]=cnf["schemes"][sch] + puts cnf.to_yaml' "$cnf" "$s" read < $tty done ```