commit 9ce0c2cd284e4c1d8925daf0926bc26fe3869406
parent 1184807871e947148e2fcef3a8f248465f8490f9
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Sat, 16 Oct 2021 10:51:01 +0000
Handler: opportunistically open plain text files with markdown
Diffstat:
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/bin/rc/Handler b/bin/rc/Handler
@@ -34,6 +34,16 @@ fn lmarkdown {
Markdown $fname
}
+fn tryfile {
+ type=`{file -m $1}
+ switch ($type) {
+ case 'text/plain';
+ lmarkdown $1
+ case *;
+ plumb $1
+ }
+}
+
fn menu {
switch ($1) {
case 'Back';
@@ -58,7 +68,7 @@ fn link {
if not echo 'can''t open file' $1
case *
if (test -d $1) ldir $1
- if not plumb $1
+ if not tryfile $1
}
}