Brad Lucas

A blog mostly about programming
July 6, 2017

Function update-work

I've had a long time practice of putting all my projects in their own repositories and keeping them in a work directory under my home directory. I even start repos for personal projects as well as various of interest items. Smaller lists and plans go into more general repos and everything is organized and backed up in a source control system.

With this I've ended up creating various functions to help manage things. For example, the following update-work bash function goes through my work directory and runs the git status command in each directory which is a git repo.

function update-work {
    pushd "$HOME/work"
    for f in `find . -maxdepth 2 -name .git`
        echo "--------------------------------------------------"
        echo "REPO: $f"
        pushd "${f%/.git}"
        git status
        echo "--------------------------------------------------"

Tags: bash git