aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmless20
-rw-r--r--mlesskey.example11
2 files changed, 29 insertions, 2 deletions
diff --git a/mless b/mless
index 03f41a1..db0a728 100755
--- a/mless
+++ b/mless
@@ -71,5 +71,21 @@ fi
nl="
"
-LESSOPEN="|$0 --filter %s" exec less -Ps"mless %f?m (message %i of %m).." -R \
- "+:e $(mseq -n .)$nl" //scan $(mseq -n :)
+while :; do
+ [ -f $HOME/.mless ] && export LESSKEY=$HOME/.mless
+ LESSOPEN="|$0 --filter %s" \
+ less -Ps"mless %f?m (message %i of %m).." -R \
+ "+:e $(mseq -n .)$nl" //scan $(mseq -n :)
+ case "$?" in
+ 0|1) exit $?;;
+ 78) # N go to next unsen message
+ mseq -C "$(mseq -r .: |
+ awk -F':2,' '$1 !~ /^</ && $2 !~ /S/ { print; exit }')";;
+ 107) # k next thread
+ mseq -C "$(mseq .+1: | grep -m1 '^[^ <]')";;
+ 100) # d mark read
+ mflag -S .
+ mseq -f | mseq -S
+ mseq -C +
+ esac
+done
diff --git a/mlesskey.example b/mlesskey.example
new file mode 100644
index 0000000..bfb08b6
--- /dev/null
+++ b/mlesskey.example
@@ -0,0 +1,11 @@
+# mless(1) keybindings
+# to update: lesskey -o ~/.mless ~/.mlesskey
+Q quit \1
+:cq quit \1
+[ prev-file
+] next-file
+S noaction E//scan\n
+` noaction E\#\n
+N quit N
+k quit k
+d quit d