diff options
-rwxr-xr-x | status | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -77,12 +77,34 @@ function status_run { # Update your mrconfig and check all registered repositories if which mr &> /dev/null; then + local mrconfig="$HOME/.custom/mrconfig-automatic" + local mrconfig_run="0" + + # Run mrconfig-updater if there's still no config + if [ ! -e "$mrconfig" ]; then + mrconfig_run="1" + else + local mrconfig_timestamp="`stat -c '%Z' $mrconfig`" + local timestamp="`date +%s`" + local mrconfig_age="$(( timestamp - mrconfig_timestamp ))" + local mrconfig_interval="3600" + + # Run mrconfig-updater only every hour or so + if (( $mrconfig_age >= $mrconfig_interval )); then + mrconfig_run="1" + fi + fi + + if [ "$mrconfig_run" == "1" ]; then + mrconfig-updater + fi + # Pipe through cat so we don't have to deal with mr's dynamic output weirdness - #mrconfig-updater && mr -m status | cat + #mr -m status | cat # Replace eventual "/mnt/crypt/home/$USER" with "~/" from output # Piping through sed also handles mr's dynamic output weirdness - mrconfig-updater && mr -m status | sed -e "s|/mnt/crypt/home/$USER/|~/|" -e "s|$HOME|~|" + mr -m status | sed -e "s|/mnt/crypt/home/$USER/|~/|" -e "s|$HOME|~|" fi # Use this as an opportunity to save our configs |