aboutsummaryrefslogtreecommitdiff
path: root/months.sh
blob: 4adb22eef93c4ca2b9017096d679c89da138713b (plain)
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
38
39
40
41
#!/bin/sh
#                        _   _
#  _ __ ___   ___  _ __ | |_| |__  ___
# | '_ ` _ \ / _ \| '_ \| __| '_ \/ __|
# | | | | | | (_) | | | | |_| | | \__ \
# |_| |_| |_|\___/|_| |_|\__|_| |_|___/
#
# Navigates through month calendars and exits with q

month=$(date +%m)
year=$(date +%Y)
cal -m $month $year
read -n 1 input

while [ "$input" != "q" ]
do
	case $input in
		l)
			clear
			month=$(($month%12+1))
			if [ $month -eq 1 ]
			then
				year=$(($year+1))
			fi
			cal -m $month $year
			read -n 1 input
			;;
		h)
			clear
			month=$(($(($month-1))%12))
			if [ $month -eq 0 ]
			then
				month=12
				year=$(($year-1))
			fi
			cal -m $month $year
			read -n 1 input
			;;
	esac
done