BASE="$HOME/.config/gitconfigs"
DATE="`date +%Y%m%d%I%M%S`"
FILENAME="gitconfig.saved"
+OPTION="$1"
+COUNTER="$BASE/counter"
+SOMETIMES="20"
# Ensure we have a base and that is minimally safe
mkdir -p $BASE
echo "Backup saved at $pwd/.git/config.$DATE"
}
+# Check option
+if [ ! -z "$OPTION" ] && [ "$OPTION" == "--sometimes" ]; then
+ if [ ! -e "$COUNTER" ]; then
+ echo 0 > $COUNTER
+ fi
+
+ COUNT="`cat $COUNTER`"
+
+ if (($COUNT >= $SOMETIMES)); then
+ echo 0 > $COUNTER
+ else
+ let COUNT++
+ echo $COUNT > $COUNTER
+ echo "Running only sometimes. This is run ${COUNT} of ${SOMETIMES}, skipping."
+ exit 1
+ fi
+fi
+
# Process everything we can find
find -type d -name .git | while read repo; do
# Get absolute folder