Skip to content

Commit

Permalink
Get rid of mmv/mcp use mblaze's mrefile instead, what was I
Browse files Browse the repository at this point in the history
thinking...

Also fix a couple nits in mailcheck.
  • Loading branch information
haqistan committed Mar 28, 2021
1 parent 9127e7c commit 7cbbe17
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 90 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Some scripts on top of mblaze that suit my workflow

BINDIR?=${HOME}/bin
SCRIPTS=mapply minbox mincall mmv mnewbox mnewdirs mpane mrespam mrm \
SCRIPTS=mapply minbox mincall mnewbox mnewdirs mpane mrespam mrm \
msign msummary munspam mdecrypt mb mdisplay foldercheck mailcheck rl

all: ${SCRIPTS}

install: all
cp ${SCRIPTS} ${BINDIR}
ln -sf ${BINDIR}/mmv ${BINDIR}/mcp
ln -sf ${BINDIR}/msign ${BINDIR}/mencrypt
6 changes: 4 additions & 2 deletions mailcheck
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ ts () {
}

shleep () {
sleep $1 & sleeper_pid=$!
sleep $1 >/dev/null 2>&1 & sleeper_pid=$!
echo $(ts) sleeping ...
wait $sleeper_pid 2>/dev/null
[ $? -ne 0 ] && echo $(ts) wakeup
sleeper_pid=0
}

wakeup () {
[ $sleeper_pid -ne 0 ] && kill $sleeper_pid && wait $sleeper_pid
[ $sleeper_pid -ne 0 ] && \
kill $sleeper_pid >/dev/null 2>&1 && \
wait $sleeper_pid
}

mailcheck () {
Expand Down
25 changes: 19 additions & 6 deletions mb
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ if [ $rl_from_profile -eq 0 ]; then
[ -n "${rl_maxhist}" ] && rl_cmd="${rl_cmd} -X ${rl_maxhist}"
fi
rl_cmd="${rl_cmd} -C ${OUR_CMDLIST} -D ${basedir}"

# parse command-line args
quiet_start=$(mhdr -h MBStartQuiet $profile)
[ -z "${quiet_start}" ] && quiet_start=0

# parse command-line args
VERBOSE=0
f=
only_one=0
args=$(getopt nq1 $*)
if [ $? -ne 0 ]; then
echo usage: $(basename $SCRIPT) [-nq1] [folder [cmd...]]
echo usage: $(basename $SCRIPT) [-nqv1] [folder [cmd...]]
exit 1
fi
set -- $args
Expand All @@ -91,6 +92,7 @@ while [ $# -ne 0 ]; do
-1) only_one=1; shift ;;
-n) CMD=mnewbox; shift ;;
-q) quiet_start=1; shift ;;
-v) VERBOSE=1; shift ;;
--) shift; break ;;
esac
done
Expand All @@ -106,6 +108,12 @@ fi
new=
[ "${CMD}" = "mnewbox" ] && new='*'

verbose () {
if [ $VERBOSE -ne 0 ]; then
echo $@
fi
}

export FOLDER # for subprocesses

# common back-end to mcom/mfwd/mrep
Expand Down Expand Up @@ -303,12 +311,17 @@ process_command () {
#+ cp your MaildirBase config setting.
#+ cp If dest-folder does not end in /new or /cur it
#+ cp is assumed you meant /new.
cmd=m${nothing}
if [ "$nothing" = "cp" ]; then
cmd="mrefile -k"
else
cmd=mrefile
fi
afterargs=$(set_args ${afterargs})
[ -z "${afterargs}" ] && {
usage "${nothing} [msgno] dest-folder"
return
}
afterargs="${basedir}/${afterargs}"
do_mscan=mscan
;;
rm) #+ rm msgno [msgno...] - remove indicated messages
Expand Down Expand Up @@ -540,7 +553,6 @@ process_command () {
give_help brief
return
;;

.) ;; #+ . - a single dot displays the current message
!*) #+ ! cmd ... - run a shell command
#+ ! this is an ancient unix tradition
Expand All @@ -553,7 +565,8 @@ process_command () {
msgno=$(tmux show-buffer)
if [ -n "${msgno}" ]; then
f=$(mpick ${msgno} 2>/dev/null)
if [ -n $f ]; then
verbose "[msgno: ${msgno} .. $f]"
if [ -n "$f" ]; then
echo ${cmd} ${beforeargs} ${msgno} ${afterargs}
if [ -n "${do_mscan}" ]; then
${cmd} ${beforeargs} ${msgno} ${afterargs} | \
Expand Down
80 changes: 0 additions & 80 deletions mmv

This file was deleted.

0 comments on commit 7cbbe17

Please sign in to comment.