E.g., I wish to have a shell script that, with a key combination (for example CTRL S, or maybe with a signal) allow me to switch between 2 or more options in runtime, like:
- print the number of process on system every 5 seconds
- CTRL S
- print the current time
- CTRL S
- again print the number of process on system every 5 seconds
- CTRL S
- print the current time
etc...
I use this construct, maybe someone could suggest another, more elegant, form:
while true; do
echo a
read -t5 -n1
done
while true; do
echo b
read -t5 -n1
done
source ./myscript.sh
while sleep 5; do ps aux | wc -l; donethe second withwhile sleep 1; do date; doneand you can switch between them using (CTRL+B)+0 or (CTRL+B)+1 in tmux?