: ' Changes:
Wed May 20 2026 Changes calender source from file to output of calendar
Wed May 20 2026 Fixed formating of wether forcast from ansiweather
Tue May 19 2026 Fixed calendar forat to tab seperated
Tue May 19 2026 Rewrite and changed name to 'now'
Sun May 17 2026 Added -F to display defined functions
Thu Apr 09 2026 Added -C to display all entries
Sat Jan 17 2026 Added clock-emoji
Fri Jan 16 2026 Removed 'now'
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"
CAL_FILE="/home/mitch/.calendar/calendar"
if [[ "$1" = "-time" ]]
then
TIME=$(etime -)
shift
else
TIME=$(etime)
fi
CURRENT_MONTH=$(date +%m)
CURRENT_YEAR=$(date +%Y)
TODAY_EPOCH=$(date -d "today" +%s)
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 ""
}
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
}
xtitle(){
printf "\033]0;%s\007" "$*"
}
moon_phase() {
local reference=592500
local period=2551443
local now=$(date +%s)
local diff=$((now - reference))
local phase=$((diff % period))
local percent=$((phase * 100 / period))
local moons=(π π π π π π π π)
local index=$((percent * 8 / 100))
if [ $index -ge 8 ]; then
index=0
fi
echo "${moons[index]}"
}
days_until(){
local target_epoch
target_epoch=$(date -d "$1" +%s) || return 1
local current_epoch
current_epoch=$(date +%s)
local diff_seconds=$(( target_epoch - current_epoch ))
local diff_days=$(( diff_seconds / 86400 ))
if [ "$diff_days" -lt 0 ]; then
echo "The date $1 has already passed ($(( -diff_days )) days ago)."
else
echo "${2}There are ${BR}$diff_days${N} days until ${SIT}$1${RIT}."
fi
}
[[ "$1" = "-V" ]] && bat -p -l bash $0 && exit
if [[ "$1" = "-F" ]]
then
[[ "$#" -eq 2 ]] && declare -f "$2" |bat -p -l bash && exit
[[ "$#" -eq 1 ]] && declare -f |bat -p -l bash && exit
fi
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${N}
{default} Shows everything
-c Edit ~/.calendar
-C Display ~/.calendar
-l List saved links, prompts to rm them
-o Open saved links, prompts to rm them
-e Edit $TASKS
-s Display one line status
-t {string} Adds entry to task list
URL key words:${BY} check, read, watch, dl${N}
# alias task='$NAME -t' in ~/.bashrc
i.e.
task "take 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
today
;;
-C)
egrep -v '^#' ~/.calendar/calendar |sed -e 's/Passed/β°οΈ/1' -e 's/call/π/1' -e 's/vacation/π/1' -e 's/birthday/π/1' -e 's/anniversary/π/1'
;;
-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 2>&1)
done
sed -i '/http/d' $TASKS 2>/dev/null
echo ' '
;;
-t)
if [[ "$*" == *"http"* ]]
then
shift
echo "$*" >>$TASKS
else
shift
echo "- [ ] $*" >>$TASKS
fi
log "New task: $*"
SHOW=y
;;
-e)
vim $TASKS
SHOW=y
;;
-s)
echo "${BG}$(fclock)${N} π ${BY}$(grep -cE 'http|https' "$TASKS")${N} β ${BY}$(grep -cE '^\-' "$TASKS")${N}"
;;
*)
clear
echo "$TIME |$(cat /tmp/mw.out) | MP $(moon_phase)"
[[ "$(hostname)" = "mitch-laptop" ]] && ssh mitch-crn -q -t /home/mitch/bin/status
echo ""
cat /tmp/fc.out | sed 's/^[[:space:]]//g'
echo ""
calendar | sed -e 's/\*//g' -e 's# #/#1' -e "s/$(date +%b)/$(date +%m)/g" >/tmp/cal.out
while read -r line || [[ -n "$line" ]]; do
event_date_raw=$(echo "$line" | awk '{print $1}')
description=$(echo "$line" | cut -d$'\t' -f2-)
event_month=$(echo "$event_date_raw" | cut -d'/' -f1)
event_day=$(echo "$event_date_raw" | cut -d'/' -f2)
if [[ "$event_month" == "$CURRENT_MONTH" ]]; then
event_full_date="$CURRENT_YEAR-$event_month-$event_day"
EVENT_EPOCH=$(date -d "$event_full_date" +%s)
diff_seconds=$((EVENT_EPOCH - TODAY_EPOCH))
diff_days=$(( (diff_seconds + 43200) / 86400 ))
if [ "$diff_days" -lt 0 ]; then
echo "[PAST] $event_date_raw: $description"
elif [ "$diff_days" -eq 0 ]; then
echo "${BG}[TODAY] $event_date_raw: $description${N}"
else
echo "In ${BLD}$diff_days days${N}: $event_date_raw - ${BC}$description${N}"|sed -E -e 's/Passed/β°οΈ/1' -e 's/[Cc]all/π/1' -e 's/([tT]ake|[pP]ickup)/π/1' -e 's/[Bb]irthday/π/1' -e 's/[Aa]nniversary/π/1'
fi
fi
done < /tmp/cal.out
echo ""
if [ $(grep -cE '^-' "$TASKS") -gt 0 ]
then
echo -n "β ${BC}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' -e 's/[wW]eb\ /πΈοΈ /1' -e 's/[pP]rep /πΉ /1' /tmp/$$.md | bat -l markdown -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"
fi
days_until "June 12" "π₯³"
days_until "June 30" "π£"
esac
[ "$SHOW" == "y" ] && $0 || exit 0