Last active
July 15, 2024 06:48
-
-
Save ImBIOS/044993843e29cd1f3e078478450a63b6 to your computer and use it in GitHub Desktop.
Automatically Add fill="currentColor" to SVG Files. This shell script recursively scans through a directory and its subdirectories to find all SVG files and adds fill="currentColor" to all path elements that don't already have a fill attribute. This is particularly useful for ensuring that SVG icons inherit the current text color when used in we…
This file contains 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 | |
# Ensure the script runs in the directory where SVG files are located | |
cd /path/to/your/svg/files | |
# Loop through all SVG files in the current directory | |
for file in *.svg; do | |
# Add fill="currentColor" to each SVG file using sed | |
sed -i 's/<svg /<svg fill="currentColor" /g' "$file" | |
done | |
echo "fill=\"currentColor\" added to all SVG files." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment