: ' Changes
Tue Feb 20 2024 Added VD db display to window title
Thu Feb 15 2024 Added version() to display version and changes
'
trap "continue" 2
[ "$1" == "-D" ] && DEBUG=1 && shift 1
PS4='$SECONDS $LINENO: '
TMOUT=30
NAME=${0##*/}
export XDG_CONFIG_HOME=~/.newsboat
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --preview '(highlight -O ansi {} || bat {}) 2> /dev/null | head -500'"
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)
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)
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" "${*}🌀${HOSTNAME}"
}
version(){
grep -E '^# Updated' $0
echo " "
sed -n "/' Changes/,/^ *$/p" <$0 |grep -E -v 'sed -n|exit 0|}'
exit 0
}
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
cp $0 /var/gopher/scripts
exit
fi
if [ "$1" == "-h" ] || [ "$1" == "--help" ]
then
fmt -s -w $(tput cols) <<END
$NAME {option}
A Menu
If no option is giventhen a menu is displayed, one cal also pass w cli shortcut as an option.
-# # Calculator
-b # Bible
-e # Bible Encyclopedia
-d # Database
-g # Gopher
-i # Internet
-l # Library (epub only)
-L # Dict lookup
-n # Notes
-r # RSS
-R # Random quote
-s # Search web
-S # Scratch pad
-v # Version
END
exit
fi
if [ "$1" == "-v" ] || [ "$1" == "--version" ]
then
version
fi
command -v bash >/dev/null || sudo apt install bash -qyy
command -v wcalc >/dev/null || sudo apt install wcalc -yyq
command -v lynx >/dev/null || sudo apt install lynx -yyq
command -v vd >/dev/null || sudo apt install visidata -yyq
command -v newsboat >/dev/null || sudo apt install newsboat -yyq
command -v lynx >/dev/null || sudo apt install lynx -yyq
command -v bat >/dev/null || sudo apt install bat-musl -yyq
[ "$DEBUG" == "1" ] && set -x
while :
do
if [ $# -lt 1 ]
then
clear
xtitle "Menu"
echo ",----[${BC}Menu${N}]"
echo "
${BC}$HOSTNAME / $(fclock) ${N}
#. Calculator
b. Bible
e. Bible Encyclopedia
d. Database
g. Gopher
i. Internet
l. Library (epub only)
n. Notes
r. RSS
R. Random quote
s. Search web
S. Scratch pad
${C}-----------------------${N}
${BR}q. Quit${N} "|boxes -d boxquote |grep -v '\,'
read -r -p "${C}Selection:${N}" -n 1 CHOICE
else
CHOICE=$(echo "$1" |cut -d'-' -f2)
[ "$1" == "-E" ] && CHOICE=E
fi
case $CHOICE in
\#)
clear
wcalc -C
;;
b)
clear
xtitle Bible
echo "${C}"
cat <<END
<Book>
Individual book
<Book>:<Chapter>
Individual chapter of a book
<Book>:<Chapter>:<Verse>[,<Verse>]...
Individual verse(s) of a specific chapter of a book
<Book>:<Chapter>-<Chapter>
Range of chapters in a book
<Book>:<Chapter>:<Verse>-<Verse>
Range of verses in a book chapter
<Book>:<Chapter>:<Verse>-<Chapter>:<Verse>
Range of chapters and verses in a book
/<Search>
All verses that match a pattern
<Book>/<Search>
All verses in a book that match a pattern
<Book>:<Chapter>/<Search>
All verses in a chapter of a book that match a pattern
Control-d to end
END
kjv
echo "${N}"
;;
e)
xtitle WOLE Encyclopedia
lynx file://localhost/home/mitch/Documents/faith/ref/wole.html
;;
d)
xtitle VisiData
cd ~/db|| error "~/Documents/db not found"
clear
DB="$(ls |fzf --ansi --color fg:-1,bg:-1,hl:46,fg+:40,bg+:233,hl+:46 --color prompt:166,border:46 --height 70% --border=sharp --prompt="➤ " --pointer="➤ " --marker="➤ ")"
xtitle "VD: ${DB}"
vd ${DB}
;;
L)
clear
lu $2
;;
g)
clear
lynx crn.hopto.org:70
;;
i)
xtitle Lynx
lynx http://crn.hopto.org
;;
l)
clear
read -n 1 -p "Continue with last book (y/n)? " READ
if [ "$READ" == "y" ]
then
epy
else
clear
epy -r
bl
echo "${BG}S${N} To search all e-books, ${BY}q${N} to quit:"
bl
read -p "Selection: " BOOK
if [ "$BOOK" == "s" ] || [ "$BOOK" == "S" ]
then
cd ~/Documents/books
epy $(find . -type f \( -name "*epub" -o -name "*epub3" -o -name "*fb2" -o -name "*azw3" -o -name "*mobi" \)|sort|fzy -p 'Book:' -l $ROWS)
else
[ "$BOOK" == "q" ] && exit 0
epy "$BOOK"
fi
fi
cd - >/dev/null
;;
n)
clear
echo "${BY}e${N}dit | ${BY}n${N}ew"
read -r -n 1 OPTION
clear
if [ "$OPTION" == "n" ]
then
read -r -p "FILE: " NAME
jot -n $NAME.md
else
jot -"${OPTION:=v}"
fi
;;
r)
ssh mitch-laptop -tt /home/mitch/bin/m -r
exit
xtitle Newsboat
[ -d ~/.newsboat/BraveSoftware ] && \rm -rf ~/.newsboat/BraveSoftware
newsboat
if [ -s ~/.newsboat/queue ]
then
podboat -a
rm ~/.newsboat/queue
fi
if [ -f ~/Downloads/get.txt ]
then
clear
cd ~/Downloads|| error "~/Downloads not found"
read -p "Run get for downloads? " -n 1 -t 5 GETIT
[ "$GETIT" == "y" ] && get
pause 5
fi
reset
;;
R)
clear;(( RANDOM%2 == 0 )) && quote || tag
pause
;;
s)
command -v lynx >/dev/null || sudo apt install lynx -yyq
xtitle "Web search"
export BROWSER=lynx
clear
ddgr -x -n 5
;;
S)
vi ~/Documents/jots/scratch.md
;;
t)
clear
~/bin/tag || error "tag not found"
pause
;;
q)
bl
echo "Bye"
exit
;;
=)
reset
exec $0
;;
!)
clear
xtitle "Run command"
echo "${BY}Hit return with no command to end.${N}"
while :
do
echo -n "[menu] $PWD $ "
read -r EXEC
[ -z "$EXEC" ] && break
eval "$EXEC"
done
pause
;;
*)
s menu
;;
esac
[ $# -eq 1 ] && exit
done