: ' Changes:
Thu Oct 23 2025 Added URL management
Thu May 22 2025 Added more emoji for tasks
Sat Feb 15 2025 Moved this from .bashrc
'
[ "$1" == "-D" ] && DEBUG=1 && shift 1
[ "$DEBUG" == 1 ] && echo "---Variables---" && set -x
PS4='$SECONDS $LINENO: '
DOW=$(date +%a)
TODAY=$(date +%m/%d)
DOM=$(date +%d)
OS=$(uname -s)
NAME=${0##*/}
DIR="$(basename $PWD)"
PDIR="$(cd ..;basename $PWD)"
TASKS="/home/mitch/etc/tasks.md"
PATH="$PATH:~/bin"
R=$(tput setaf 1)
BR=$(tput setaf 1; tput bold)
G=$(tput setaf 2)
BG=$(tput setaf 2; tput bold)
Y=$(tput setaf 3)
BY=$(tput setaf 3; tput bold)
B=$(tput setaf 4)
BM=$(tput setaf 5; tput bold)
BC=$(tput setaf 6; tput bold)
C=$(tput setaf 6)
BL=$(tput setaf 7; tput bold)
BLD=$(tput bold)
N=$(tput sgr0)
SIT=$(tput sitm)
RIT=$(tput ritm)
UL=$(tput smul)
NL=$(tput rmul)
RV=$(tput rev)
ROWS=$(tput lines)
COLS=$(tput cols)
[ "$DEBUG" == 1 ] && set +x && read -p "${N}-Continue-" -n 1 x
bl(){
[ "$DEBUG" == "1" ] && set -x
echo ""
}
center () {
[[ $# == 0 ]] && return 1;
declare -i TERM_COLS="$(tput cols)";
declare -i str_len="${#1}";
[[ $str_len -ge $TERM_COLS ]] && {
echo "$1";
return 0
};
declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))";
[[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" ";
filler="";
for ((i = 0; i < filler_len; i++ ))
do
filler="${filler}${ch}";
done;
printf "%s%s%s" "$filler" "$1" "$filler";
[[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}";
printf "\n";
return 0
}
html(){
vim -f +"syn on" +"set nonu" +"set foldenable!" +"set nospell" +"run! syntax/2html.vim" +"wq" +"q" $1
}
log(){
[ "$DEBUG" == "1" ] && set -x
logger -i -t "$NAME" "$*"
}
pause(){
[ "$DEBUG" == "1" ] && set -x
[ "$1" == "-nt" ] && TMOUT="" && shift
echo "$BY";
if [ $# -gt 0 ]
then
read -t $1 -r -p "${C}Hit any key (${BY}$1${C} second timeout)${N}" -n 1 FOO;
else
read -r -p "${C}Hit any key${N}" -n 1 FOO;
fi;
bl
}
strip-tags(){
sed -e 's/<[^>]*.//g' -
}
xtitle(){
printf "\033]0;%s\007" "$*"
}
if [ "$1" == "-E" ]
then
vim $0
sed -i -e "7s/.*/# Updated....: $(date)/" $0
log "Updated $0"
html $0
cp $0 /var/www/unix
mv $0.html /var/www/unix
exit
fi
if [ "$1" == "-h" ] || [ "$1" == "--help" ]
then
fmt -s -w $(tput cols) <<END
${BG}$NAME${N}
Displays calender, tasks, and urls to look at.
${BC}Options{$}
{default} Shows everything
-c Edit ~/.calendar
-l List saved links, prompts to rm them
-o Open saved links, prompts to rm them
-e Edit $TASKS
-t {string} Adds entry to task list
URL key words:${BY} check, read, watch, dl${N}
# alias task='today -t' in ~/.bashrc
i.e.
task "task out trash"
task read http://crn.hopto.org/bible/
END
exit
fi
command -v bash >/dev/null || sudo apt install bash -qyy
[ "$DEBUG" == 1 ] && echo "---Functions---" && typeset -F && read -p "${N}-Continue-" -n 1 x
[ "$DEBUG" == 1 ] && echo "---Main---" && set -x
case "$1" in
-c)
vim ~/.calendar/calendar
SHOW=y
;;
-l)
\grep -iE 'http|https' "$TASKS" |sed -e 's/^check/🔍/1' -e 's/^read/👓/1' -e 's/^watch/🎬/1' -e 's/^dl/⬇️/1' -e 's/^pipe/🤓/1' -e 's/^food/🍲/1'
[ "$(grep -c http $TASKS)" -gt 0 ] && read -p "Remove them? " -n 1 ANS
[ "$ANS" == "y" ] && sed -i '/http/d' $TASKS
echo ' '
;;
-o)
for URL in $(grep -iE 'http|https' $TASKS | awk '{print $NF}')
do
xdg-open "$URL" >/dev/null
done
[ "$(grep -c http $TASKS)" -gt 0 ] && read -p "Remove them? " -n 1 ANS
[ "$ANS" == "y" ] && sed -i '/http/d' $TASKS
echo ' '
;;
-t)
if [[ "$*" == *"http"* ]]
then
shift
echo "$*" >>$TASKS
else
shift
echo "- [ ] $*" >>$TASKS
fi
log "New task: $*"
SHOW=y
;;
-e)
vim $TASKS
SHOW=y
;;
*)
clear
if [ $(tput cols) -gt 92 ]
then
~/bin/now
else
center "⏰ ${BG}$(fclock)${N}"
ncal -b -3
fi
echo "$BY"
egrep ^$(date +%m) ~/.calendar/calendar |sed -e 's/birthday/🎂/1' -e 's/anniversary/💍/1'
[ $(egrep -c ^$(date +%m) ~/.calendar/calendar) -gt 0 ] && bl
if [ $(grep -cE '^-' "$TASKS") -gt 0 ]
then
echo "✅ ${BY}Tasks:${N}"
cat $TASKS|grep -vE 'URL|Enter:|http|https' >/tmp/$$.md
sed -e 's/[aA]ppointment/⏰ /1' -e 's/[cC]all/☎️ /1' -e 's/[hH]ouse/🏡 /1' -e 's/[cC]ar/🚙/1' /tmp/$$.md | bat -p
echo ${N}
else
~/bin/quote
fi
LINKS=$(grep -cE 'http|https' "$TASKS")
if [ $LINKS -gt 0 ]
then
echo "🔗 ${BY}Links: ${BC}$LINKS${N}"
echo -n "$UL"
echo ${N}
fi
esac
[ "$SHOW" == "y" ] && $0 || exit 0