Skip to content

Instantly share code, notes, and snippets.

@rxw1
Last active May 23, 2018 01:31
Show Gist options
  • Save rxw1/b83a8d0c3d510ffa1ee342b5d5a8cb65 to your computer and use it in GitHub Desktop.
Save rxw1/b83a8d0c3d510ffa1ee342b5d5a8cb65 to your computer and use it in GitHub Desktop.
Get hex values and color names for Googles Material Design Color Palette
#!/usr/bin/env zsh
curl -s https://material.io/guidelines/style/color.html |\
pup 'div.col-list section.module-module-module.col-3:nth-last-of-type(n+2) div span text{}' |\
awk '/^[A-Z][a-z]+/{cat=$0} /^[A]{0,1}[0-9]{2,3}/{shade=$0} /^#[0-9A-F]{6}/ {printf("%4s, %-11s, %s\n",shade,cat,$0)}' |\
cat -n |\
sort -t, -k3 |\
tac |\
uniq -f1 |\
sort -nk1 |\
cut -f2- |\
column -t -s,
#!/usr/bin/awk -f
/^[A-Z][a-z]+/ {
cat=$0
}
/^[A]{0,1}[0-9]{2,3}/ {
shade=$0
}
/^#[0-9A-F]{6}/ {
printf("%4s, %-11s, %s\n", shade, cat, $0)
}
#!/bin/zsh
curl -s https://material.io/guidelines/style/color.html | pup 'div.col-list section.module-module-module.col-3:nth-last-of-type(n+2) div span text{}' |\
./parse.awk | cat -n | sort -t, -nk2 | tac | uniq -f1 | sort -nk1 | cut -f2- | column -t -s, -R1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment