anything-scripts

Disposable scripts to fix day to day problems.
git clone git://soucy.cc/anything-scripts.git
Log | Files | Refs

hexcolors-extractor.sh (572B)


      1 #!/bin/bash
      2 
      3 . ./mo
      4 
      5 REPO_PATH="$1"
      6 unset -v COLORS[*]
      7 declare -a COLORS
      8 
      9 [ -f "hexcolors.html" ] && rm "hexcolors.html"
     10 
     11 for css in $(find "$REPO_PATH/" -type f \( -name "*.css" -o -name "*.scss" \)); do
     12     #echo "$css"
     13 
     14     if [[ ! -a "$css" ]]; then
     15 	    echo "File not found"
     16 	    exit 1
     17     fi
     18 
     19     grep -o '\#[0-9a-fA-F]\{3,6\}' "$css"
     20 
     21 done | tr '[:upper:]' '[:lower:]' | sort -n | uniq > "hexcolors.data"
     22 
     23 while read -r line ; do
     24     echo "Processing ${line}"
     25 
     26     COLORS+=("${line}")
     27 done < "hexcolors.data"
     28 
     29 mo "hexcolors-extractor.mustache" > "hexcolors.html"