scripts

Various scripts for UNIX-like systems
git clone https://git.tronto.net/scripts
Download | Log | Files | Refs | README

mblaze-extras (946B)


      1 #!/bin/sh
      2 
      3 # Useful extra commands for mblaze
      4 
      5 # Requires: mblaze, mpop
      6 
      7 # Usage: mblaze-extras command
      8 # List of commands:
      9 #	get [filter]
     10 #	pick [field]
     11 #	save
     12 #	scan [folder]
     13 
     14 menu=${MENU:-dmenu}
     15 mdir=$HOME/mail
     16 mpopdir=$HOME/.config/mpop
     17 
     18 mbextra_scan() {
     19 	folder=${1:-inbox}
     20 	mlist -t $mdir/$folder | mthread | mseq -S
     21 	mscan
     22 }
     23 
     24 mbextra_get() {
     25 	mpop --filter=$mpopdir/filter-$1.sh
     26 	minc -q $mdir/inbox
     27 	mbextra_scan inbox
     28 }
     29 
     30 mbextra_pick() {
     31 	field=$1
     32 	shift
     33 	mpick -t "$field =~~ \"$@\""
     34 }
     35 
     36 mbextra_save() {
     37 	dir=$2
     38 	[ -z "$dir" ] && dir=$(dmenu-filepicker)
     39 	mkdir -p "$dir"
     40 
     41 	if [ ! -d "$dir" ]; then
     42 		echo "No directory selected, skipping."
     43 	else
     44 		cd "$dir"
     45 		mshow -x $1
     46 	fi
     47 }
     48 
     49 if [ -z "$1" ]; then
     50 	echo "Usage: mblaze-extras COMMAND"
     51 elif [ "$1" = "scan" ]; then
     52 	mbextra_scan $2
     53 elif [ "$1" = "get" ]; then
     54 	mbextra_get $2
     55 elif [ "$1" = "save" ]; then
     56 	shift
     57 	mbextra_save $@
     58 elif [ "$1" = "pick" ]; then
     59 	shift
     60 	mbextra_pick $@
     61 fi