aboutsummaryrefslogtreecommitdiff
path: root/sh/profile.d/downloads.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sh/profile.d/downloads.sh')
-rw-r--r--sh/profile.d/downloads.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/sh/profile.d/downloads.sh b/sh/profile.d/downloads.sh
new file mode 100644
index 00000000..fb8dd64a
--- /dev/null
+++ b/sh/profile.d/downloads.sh
@@ -0,0 +1,28 @@
+# Only if shell is interactive
+case $- in
+ *i*) ;;
+ *) return ;;
+esac
+
+# Only if not in a tmux window
+[ -z "$TMUX" ] || return
+
+# Not if ~/.hushlogin exists
+[ -e "$HOME"/.hushlogin ] && return
+
+# Not if ~/.downloads doesn't
+[ -f "$HOME"/.downloads ] || return
+
+# Count files in each directory, report if greater than zero
+(
+ while IFS= read -r dir ; do
+ case $dir in
+ '#'*) continue ;;
+ esac
+ [ -d "$dir" ] || continue
+ set -- "$dir"/*
+ [ -e "$1" ] || shift
+ [ "$#" -gt 0 ] || continue
+ printf '\nYou have %u unsorted files in %s.\n\n' "$#" "$dir"
+ done < "$HOME"/.downloads
+)