Feature Creep 2026, 37 - Some Bash Scripting
I don't really mind writing the commands by hand, but it could always be shorter. I don't really gain anything from doing it per hand, so might as well write some bash. Basically, I want to write a script that deletes all files with a given extension. That is relatively straight forward and not a lot of code, so let's get it over with
find . -type f -name '*.png' -delete
I would usually do this with rm, but I apparently find has a -delete flag.
That is the easier part of this week's programme. Because I develop on several machines, I want to automate the git stuff as far as I can as well. That is best done by two steps:
- Have the machine read my git credentials from a file
- Build a bash script that iterates through all directories in the space I have my git projects in.
The first one is a very solved problem, because people seem to generally want to avoid entering passwords. It's solved so thoroughly, that the git command line has a flag for it, namely:
git config --global credential.helper store
If that is set true, then git will remember the credentials for a pretty second. The other part is also relatively straight-forward
for dir in .
do
cd ${dir%*/}
git stash
git pull
git stash pop
git commit
git push
cd ..
done