: ' Changes
Thu May 30 2024 Cleaned up -l list option display
Wed May 29 2024 Added test effects to menu display for fun (https://github.com/ChrisBuilds/terminaltexteffects)
Fri Apr 05 2024 Added window title to playing games
Fri Apr 05 2024 Changed Solitaire and added back in klondike2 as well
Thu Mar 14 2024 Added -l option to list menu options
Thu Feb 15 2024 Added version() to display version and changes
'
trap "continue" 2
[ "$1" == "-D" ] && DEBUG=1 && shift 1
DATE=$(date +"%a %b %d")
PS4='$SECONDS $LINENO: '
OS=$(uname -s)
NAME=${0##*/}
TMOUT=60
export PATH=/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:$PATH
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)
html(){
vim -f +"syn on" +"set nonu" +"set foldenable!" +"set nospell" +"run! syntax/2html.vim" +"wq" +"q" $1
}
pause(){
echo " "
echo -n "Hit any key to continue: "
read -n 1 x
}
xtitle(){
[ "$DEBUG" == "1" ] && set -x
printf "\033]0;${*}🌀${HOSTNAME}\007"
}
log(){
[ "$DEBUG" == "1" ] && set -x
logger -i -t "$NAME" "$*"
}
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
log "Updated $0"
exit
fi
if [ "$1" == "-v" ] || [ "$1" == "--version" ]
then
version
fi
command -v ppt >/dev/null || sudo apt install bsdgames -yyq
command -v klondike2 >/dev/null || wget http://crn.hopto.org/unix/klondike2
command -v boxes >/dev/null || sudo apt install boxes -yy
command -v rogue >/dev/null || sudo apt install bsdgames-nonfree -yy
command -v nettoe >/dev/null || sudo apt install nettoe -yy
command -v freesweep >/dev/null || sudo apt install freesweep -yy
command -v vitetris >/dev/null || sudo apt install vitetris -yy
command -v ninvaders >/dev/null || sudo apt install ninvaders
[ "$DEBUG" == "1" ] && set -x
while :
do
if [ $# -lt 1 ]
then
clear
xtitle "Games"
echo "${BC}----[Games]----${N}
${BY}$(fclock)${N}
2. 🎴 Blackjack
b. 🟠 Backgammon
h. 🤓 Hangman
i. 👾 Invaders
k. 🎴 Klondike
m. 🚦 Milleborn
M. 💣 Minesweeper
p. 🎴 Poker
r. 🏹 Rogue
s. 🎴 Solitaire
t. 🔳 Tetris
T. 🔖 Tic-Tac-Toe
y. 🎲 Yahtzee
w. 🔍 Word Search
-----------------------
${BR}q. Quit${N}
"
read -p Selection: -n 1 CHOICE
else
CHOICE=$(echo "$1" |cut -d'-' -f2)
[ "$1" == "-E" ] && CHOICE=E
fi
case $CHOICE in
b)
xtitle "🟠 Backgammon"
clear
echo $BC
/usr/games/backgammon -n -w
echo ${N}
;;
2)
xtitle "🎴 21"
clear
bj
pause
;;
h)
xtitle "🤓 Hangman"
clear
echo "${Y}"
/usr/games/hangman -d ~/etc/words.txt
echo ${N}
;;
i)
xtitle "👾 Ninvaders"
ninvaders
;;
k)
xtitle "🎴 Klondike"
klondike2
;;
l)
clear
grep ') #' $0| sed 's/^[ \t]*//' |grep -v grep
;;
m)
xtitle "🚦 Milleborn"
clear
echo "${Y}"
/usr/games/mille
echo ${N}
;;
M)
xtitle "💣 Minesweeper"
freesweep -m 5
;;
p)
xtitle "🎴 Poker"
clear
videopoker -mh
pause
;;
r)
xtitle "🏹 Rogue"
clear
echo "$BC"
cd ~/etc
if [ -f rogue.save ]
then
rogue rogue.save
else
rogue
fi
if [ -f rogue.save ]
then
ft "Game saved!"
else
ft "RIP fallen hero!"
fi
cd - >/dev/null
sleep 3
;;
s)
xtitle "🎴 Solitaire"
cd ~/bin/csol-master && ./csol 2>/dev/null
cd - >/dev/null
;;
t)
xtitle "🔳 Tetris"
clear
vitetris
pause
;;
T)
xtitle "🔖 tic-tac-toe"
clear
nettoe
clear
;;
y)
xtitle "🎲 Yahtzee"
clear;echo ${BC}
yaht1
pause
;;
q)
clear
ft Bye
echo -e "\n"
exit
;;
w)
xtitle "🔍 Word Search"
clear
cd ~/bin/wordsearch-master
./wordsearch -t black
cd -
;;
!)
clear
echo "${C}Hit return with no command to end.${N}"
while :
do
echo -n "[menu] $PWD $ "
read EXEC
[ -z "$EXEC" ] && break
eval "$EXEC"
done
pause
;;
=)
reset
exec $0
;;
*)
xtitle "🌘 Screen saver"
xs
;;
esac
[ $# -eq 1 ] && exit
done