Created
July 14, 2020 15:55
-
-
Save sidpalas/fbe53ec4e9ecf01d552abff7223d4e1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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