#!/bin/bash # # Check the overall status of your work. # # Parameters BASENAME="`basename $0`" # Usage function status_usage { echo "usage: $BASENAME [-l|--long] [-d|--delay N] [project]" if [ -z "$1" ]; then exit 1 else exit $1 fi } # See https://stackoverflow.com/questions/2721946/cross-platform-getopt-for-a-shell-script#4300224 function status_options { getopt -T > /dev/null if [ $? -eq 4 ]; then # GNU enhanced getopt is available ARGS=`getopt --name "$BASENAME" --long loop,delay: --options ld: -- "$@"` else # Original getopt is available (no long option names, no whitespace, no sorting) ARGS=`getopt ld: "$@"` fi if [ $? -ne 0 ]; then echo "$BASENAME: usage error" >&2 status_usage 2 fi eval set -- $ARGS while [ $# -gt 0 ]; do case "$1" in l|--loop) LOOP="yes";; d|--delay) DELAY="$2" shift;; --) shift break;; *) status_usage ;; esac shift done if [ $# -gt 0 ]; then PROJECT="$1" shift fi } # Run status function status_run { if [ ! -z "$PROJECT" ]; then # Check the status of the given project cd $PROJECT &> /dev/null && git status elif git status &> /dev/null; then # Check the status of the current project mr status else # Ensure we are in the home folder cd # Check your reminders if [ -e "$HOME/.reminders" ]; then remind ~/.reminders | grep -v '^No reminders.$' fi # Update your mrconfig and check all registered repositories mrconfig-updater && mr -m status # Check your TODO lists todo # Check if you have mails to send postponed # Check unread mails unread-mails # Check if are dangling downloaded files if [ -e "$HOME/load" ] && [ ! -z "`ls -1 ~/load/`" ]; then echo "Dangling files at ~/load:" echo "" ls -lh ~/load/ fi fi } # Options status_options $@ # Dispatch if [ "$LOOP" == "yes" ]; then PROJECT="" if [ -z "$DELAY" ]; then DELAY="60" fi while true; do clear status_run sleep $DELAY done else status_run fi