-
Notifications
You must be signed in to change notification settings - Fork 2
Identify similar colours
This collection of one-line shell-scripts aims at ultimately replacing hooks/pre-commit
with something better.
grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort
grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort | sed -e 's/^\(....\)\(..\)/\1 0x\2/' -e 's/^\(..\)\(..\)/\1 0x\2/' -e 's/^\(..\)/0x\1/'
printf '%d %d %d %s\n' $(grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort | sed -e 's/^\(....\)\(..\)/\1 0x\2/' -e 's/^\(..\)\(..\)/\1 0x\2/' -e 's/^\(..\)/0x\1/') | column -t
Notes:
-
$(wc -l outfile.txt)
may count a line too much (i.e. the concluding\n
aka "newline" character): Use$(($(wc -l outfile.txt)-1)
then. - If a PNG image is wanted, replace
> outimage.ppm
by either| pnmtopng > outimage.png
or| convert - outimage.png
or| ffmpeg -i - outimage.png
/> outimage.ppm; ffmpeg -i outimage.ppm outimage.png
.
grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort | tee outfile.txt | cut -f 1 -d ' ' | sed -e p -e p -e p -e p -e p -e p -e p | tr -d '\n' | xxd -r -ps | rawtoppm 8 $(wc -l outfile.txt) > outimage.ppm
grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed -e 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' -e 's/^\(..\)\(..\)\(..\) /\2\1\3 /' | sort | tee outfile.txt | cut -f 1 -d ' ' | sed -e p -e p -e p -e p -e p -e p -e p | tr -d '\n' | xxd -r -ps | rawtoppm -grb 8 $(wc -l outfile.txt) > outimage.ppm
grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed -e 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' -e 's/^\(..\)\(..\)\(..\) /\3\2\1 /' | sort | tee outfile.txt | cut -f 1 -d ' ' | sed -e p -e p -e p -e p -e p -e p -e p | tr -d '\n' | xxd -r -ps | rawtoppm -bgr 8 $(wc -l outfile.txt) > outimage.ppm
Other RGB-permutations can be constructed accordingly.