Skip to content

Instantly share code, notes, and snippets.

@belchior
Last active September 18, 2015 13:21
Show Gist options
  • Save belchior/548dc5cee561fa7179b1 to your computer and use it in GitHub Desktop.
Save belchior/548dc5cee561fa7179b1 to your computer and use it in GitHub Desktop.
function gitstatus {
local www='/var/www/html';
local mydir=($PWD);
local notStaged='Changes not staged';
local toCommit='Changes to be committed';
local isAhead='is ahead';
local ok='nothing to commit';
cd $www;
printf "\n# ------------------------------ gitstatus ------------------------------ #\n";
for dirname in `ls -d */`; do
cd $dirname;
if [ -d ".git" ]; then
local msg="$PWD -";
if [ "`git status | grep -o "$notStaged"`" = "$notStaged" ]; then
msg="$msg <$notStaged>";
fi
if [ "`git status | grep -o "$toCommit"`" = "$toCommit" ]; then
msg="$msg <$toCommit>";
fi
if [ "`git status | grep -o "$isAhead"`" = "$isAhead" ]; then
msg="$msg <$isAhead>";
fi
if [ "`git status | grep -o "$ok"`" = "$ok" ]; then
msg="$msg <$ok>";
fi
printf "$msg\n";
fi
cd $www;
done;
printf "# ----------------------------------------------------------------------- #\n\n";
cd $mydir;
}
gitstatus;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment