View difference between Paste ID: S2KkzDUr and evSYiPTe
SHOW: | | - or go back to the newest paste.
1
#!/bin/bash
2
# betlog - 2019-04-27
3
# modified from : https://stackoverflow.com/questions/10679188/casing-arrow-keys-in-bash
4
#
5
MIN=00
6
MAX=99
7
#-------
8-
8+
9
echo $(printf %02d $count)
10
escape_char=$(printf "\u1b")
11
while :; do
12
	read -rsn1 mode # get 1 character
13
	if [[ $mode == $escape_char ]]; then
14
		read -rsn2 mode # read 2 more chars
15
	fi
16
	case $mode in
17
		'q') echo QUITTING ; exit ;;
18
		'[A') echo UP ;;
19
		'[B') echo DN ;;
20-
			if [[ $count-1 -lt $MIN ]]; then
20+
21
			echo -ne "RESET \a\n"
22
			let count=00
23-
				let count=count-1
23+
			echo $(printf %02d $count)
24
			;;
25
		'[C') #rightarrow
26
			if [[ $count -gt $MAX-1 ]]; then
27
				echo -ne "NOPE \a\n"
28
			else
29
				let count=count+1 
30
				echo $(printf %02d $count)
31
			fi
32
			;;
33
		*) >&2 echo 'ERR bad input'; return ;;
34
	esac
35
done