File: mlsearch.sh

package info (click to toggle)
mlterm 3.9.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,340 kB
  • sloc: ansic: 154,713; sh: 5,302; cpp: 2,953; objc: 2,776; java: 2,472; makefile: 2,445; perl: 1,674; xml: 44
file content (35 lines) | stat: -rwxr-xr-x 607 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh

reset_state()
{
	printf "\x1b]5379;search_$1\x07"
	stty echo
	exit 0
}

if test ${#} = 0 ; then
	echo "Reset searching position."
	printf "\x1b]5379;search_$1\x07"
	exit  0
elif test ${#} = 1 ; then
	pat=$1
	dir="prev"
elif test "$1" = "-h" -o ${#} != 2 ; then
	echo "Usage: mlsearch (prev|next) [pattern]"
	exit  0
else
	pat=$2
	dir=$1
fi

echo "Press Enter key to continue searching. Press ^C to exit."

trap "reset_state $dir" 2
stty -echo 
printf "\x1b]5379;search_$dir %s\x07" "$pat"
read input
while  true
do printf "\x1b]5379;search_$dir %s\x07" "$pat" ; read input
done

reset_state $dir