summaryrefslogtreecommitdiff
path: root/bin/readmail
blob: 5466088a3a14ffd6ecf2b08b5be1287970573546 (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
#!/bin/sh

dir=~/mail/"${1:-INBOX}"

while true; do
	mlist "$dir" | msort -dr | mseq -S | MBLAZE_PAGER=cat mscan
	read -r addr cmd || break
	if [ -z "$cmd" ]; then
		cmd="$addr"
		addr=.
	fi
	case "$cmd" in
		g) mbsync primary && minc ~/mail/* >/dev/null ;;
		C) mseq -C "$addr" ;;
		c*) dir=~/mail/"${cmd#c}" ;;
		s) mshow "$addr" && mflag -S "$addr" >/dev/null ;;
		a) mrefile "$addr" ~/mail/Archive ;;
		m*) mrefile "$addr" ~/mail/"${cmd#m}" ;;
		f*) mflag -"${cmd#f}" "$addr" >/dev/null ;;
		h)
			echo 'Commands:'
			echo 'g - fetch mail'
			echo 'C - set the sequence to messages'
			echo 'cFOLDER - cd to FOLDER'
			echo 's - show messages'
			echo 'a - archive messages'
			echo 'mFOLDER - move messages to FOLDER'
			echo 'fFLAGS - set FLAGS on messages. Uppercase sets, lowercase unsets.'
			echo '	d=draft, f=flagged, p=passed, r=replied, s=seen, t=trashed.'
			echo 'h - print this message'
			echo
			;;
		q) break ;;
	esac
done
echo 'Syncing changes...'
mbsync primary