From a765f11df28bca3a3c0bc53f8d2d873f56e79a9c Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Sun, 1 Oct 2023 16:31:47 -0400 Subject: [PATCH] add alias to send desktop notifications --- .config/bash/.bashrc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.config/bash/.bashrc b/.config/bash/.bashrc index 12fe256..13f6b00 100644 --- a/.config/bash/.bashrc +++ b/.config/bash/.bashrc @@ -16,13 +16,16 @@ alias la="ls -A" # -F appends a character to each entry in the listing to indicate the file type (e.g '/' for directories and '*' for executables) alias l="ls -CF" +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=normal -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + # Nice line headers for logs ERROR=$'\033[39;41mERROR:\033[0m' SUCCESS=$'\033[39;42mSUCCESS:\033[0m' WARNING=$'\033[39;43mWARNING:\033[0m' INFO=$'\033[39;44mINFO:\033[0m' - # -------------- Functions # list directory and cd into it sd() { @@ -199,3 +202,8 @@ command -v bun > /dev/null 2>&1 if [ $? -ne 0 ]; then echo -e "$WARNING bun is not installed" fi + +command -v notify-send > /dev/null 2>%1 +if [ $? -ne 0 ]; then + echo -e "$WARNING notify-send is not installed. Will affect the alias: \033[34;49;1malert\033[0m" +fi