: ' Changes:
Tue Jun 23 2026 Went back to basic calendar
Wed May 20 2026 Added wttr full weather report
Wed May 20 2026 Fixed formating of wether forcast from ansiweather
'
[ "$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)
if [[ -z "$WTTR_PARAMS" ]]; then
if [[ -t 1 ]] && [[ "$(tput cols)" -lt 125 ]]; then
WTTR_PARAMS+='n'
fi 2> /dev/null
for _token in $( locale LC_MEASUREMENT ); do
case $_token in
1) WTTR_PARAMS+='m' ;;
2) WTTR_PARAMS+='u' ;;
esac
done 2> /dev/null
unset _token
export WTTR_PARAMS
fi
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 + 1 ))
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
}
wttr(){
local location="${1// /+}"
command shift
local args=""
for p in $WTTR_PARAMS "$@"; do
args+=" --data-urlencode $p "
done
curl -fGsS -H "Accept-Language: ${LANG%_*}" $args --compressed "wttr.in/${location}"
}
[[ "$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
-w Wttr full display
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 "$(wclock) π ${BY}$(grep -cE 'http|https' "$TASKS")${N} β ${BY}$(grep -cE '^\-' "$TASKS")${N}"
;;
-w)
wttr
;;
*)
clear
hclock -
echo -e "\b$(cat /tmp/mw.out| sed 's/^.*L/L/g') | 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 ""
echo "π
${BLD}$(date "+%A %B %d, %Y")${N}"
calendar -A 3 | sed -e 's/\*//g' -e "s/$(date "+%b %d")/${BG}Today${N}/g"
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}
fi
LINKS=$(grep -cE 'http|https' "$TASKS")
if [ $LINKS -gt 0 ]
then
echo "π ${BY}Links: ${BC}$LINKS${N}"
echo " "
fi
esac
[ "$SHOW" == "y" ] && $0 || exit 0