Skip to content

Instantly share code, notes, and snippets.

@sidpalas
Created July 14, 2020 15:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidpalas/fbe53ec4e9ecf01d552abff7223d4e1b to your computer and use it in GitHub Desktop.
Save sidpalas/fbe53ec4e9ecf01d552abff7223d4e1b to your computer and use it in GitHub Desktop.
#!/bin/bash
# Array of options
colors=(000000 ffc857)
num_colors=${#colors[@]}
# Find current title color
cur_value=$(sed -n -e 's/^.*title_color=//p' readme.md | cut -c 1-6)
# Get index of current title color in colors array
for i in "${!colors[@]}"; do
if [[ "${colors[$i]}" = "${cur_value}" ]]; then
cur_index="${i}";
fi
done
# Get next index in array (looping back if too large)
next_index=$((($cur_index + 1) % $num_colors))
next_color=${colors[$next_index]}
# Find and replace within README
sed -i .bak "s/title_color=.\{6\}/title_color=$next_color/" README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment