add alias to send desktop notifications

This commit is contained in:
jc 2023-10-01 16:31:47 -04:00
commit a765f11df2
No known key found for this signature in database

View file

@ -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) # -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" 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 # Nice line headers for logs
ERROR=$'\033[39;41mERROR:\033[0m' ERROR=$'\033[39;41mERROR:\033[0m'
SUCCESS=$'\033[39;42mSUCCESS:\033[0m' SUCCESS=$'\033[39;42mSUCCESS:\033[0m'
WARNING=$'\033[39;43mWARNING:\033[0m' WARNING=$'\033[39;43mWARNING:\033[0m'
INFO=$'\033[39;44mINFO:\033[0m' INFO=$'\033[39;44mINFO:\033[0m'
# -------------- Functions # -------------- Functions
# list directory and cd into it # list directory and cd into it
sd() { sd() {
@ -199,3 +202,8 @@ command -v bun > /dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo -e "$WARNING bun is not installed" echo -e "$WARNING bun is not installed"
fi 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