From 2913f3c95f85a12c424732c39a1b2900958cde71 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Fri, 23 Jul 2021 18:47:05 +0800 Subject: [PATCH] [feature] create and open markdown file --- cli/ranger/commands.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cli/ranger/commands.py b/cli/ranger/commands.py index 38ce93b..8b9fd2c 100644 --- a/cli/ranger/commands.py +++ b/cli/ranger/commands.py @@ -226,3 +226,26 @@ class mediacut_open(Command): read=False, ) self.fm.loader.add(obj) + + +class md(Command): + """ + :typeora + + create a markdown file with typora + """ + def execute(self): + import subprocess + import os.path + filename = self.arg(1) + if not filename.endswith(".md"): + filename += ".md" + if not os.path.exists(filename): + open(filename, 'a').close() + descr = "editing" + obj = CommandLoader( + args=['x-open', filename], + descr=descr, + read=True + ) + self.fm.loader.add(obj)