env/scripts/projects-prune.sh

21 lines
644 B
Bash
Executable File

#!/bin/bash
# PROJECT DIR PRUNING SCRIPT
# Lists projects in current directory with a clean git status,
# sorted in reverse by date modified
printf "%-40s%-20s%s\n" 'Clean git, oldest to newest' 'Date Modified' 'Size'
printf "%-40s%-20s%s\n" '===========================' '=============' '===='
for pdir in $(ls -r1dt */); do
cd $pdir
git status 2> /dev/null | grep 'nothing to commit, working tree clean' 1> /dev/null
if [ "$?" == "0" ]; then
dirModDate=$(date -r . +"%m/%d/%Y")
dirSize=$(du -sh . | awk '{print $1}')
printf "%-40s\e[32m%-20s\e[0m%s\n" $pdir $dirModDate $dirSize
fi
cd ..
done