~bronikowski/focu.sh

focu.sh/focu.sh -rwxr-xr-x 499 bytes
8a557374Emil Oppeln-Bronikowski It does not get any better 3 months ago
                                                                                
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
36
37
#!/bin/bash

if [ "$1" = "" ]; then
	echo "Uage: focu.sh <filename>"
	exit 1;
else
	output=$1
fi

lines_added=0
clear_and_align() {
	lines=`tput lines`
	half=`echo $lines/2-1 | bc`
	tput clear
	for i in $(seq 1 $half);
	do
		echo
	done
}

goodbye() {
	clear_and_align
	echo "W R I T I N G   S E S S I O N   T E R M I N A T E D."
	echo
	echo "$lines_added   L I N E S   A D D E D"
	exit
}

trap goodbye SIGINT

while :
do
	clear_and_align
	read line
	echo $line >> "$output"
	((lines_added+=1))
done