Commits

Etienne Perot  committed d083524

Add command blacklist to undistract-me for which no notification should happen

  • Participants
  • Parent commits 6306e4f

Comments (0)

Files changed (1)

File modules/console/files/zsh/.zsh/custom/plugins/undistract-me/undistract-me.plugin.zsh

+UNDISTRACT_ME_CMD_BLACKLIST=(
+	screen
+	ssh
+	man
+	wine
+	less
+	more
+	most
+)
+
 undistract_me_preexec() {
 	UNDISTRACT_ME_CMD=${${${(pj:\\\\n:)${(f)1}}//\%/%%}//\\/\\\\}
 	UNDISTRACT_ME_CMD_START_TIME=$(date +%s)
 	local end_time duration
 	if [ "$UNDISTRACT_ME_CMD" != '' ]; then
 		end_time=$(date +%s)
-		((duration=$end_time - $UNDISTRACT_ME_CMD_START_TIME))
-		if [ "$duration" -gt 15 ]; then
-			notify-send --urgency=low --expire-time=1500 --icon=utilities-terminal 'Command executed' "'$UNDISTRACT_ME_CMD' ended in $duration seconds."
+		validCommand='true'
+		for cmd in "${UNDISTRACT_ME_CMD_BLACKLIST[@]}"; do
+			if echo "$UNDISTRACT_ME_CMD" | grep -qP "^(?:sudo)?\s*$cmd\b"; then
+				validCommand=''
+				break
+			fi
+		done
+		if [ -n "$validCommand" ]; then
+			((duration=$end_time - $UNDISTRACT_ME_CMD_START_TIME))
+			if [ "$duration" -gt 15 ]; then
+				notify-send --urgency=low --expire-time=1500 --icon=utilities-terminal 'Command executed' "'$UNDISTRACT_ME_CMD' ended in $duration seconds."
+			fi
 		fi
 	fi
 	unset UNDISTRACT_ME_CMD