aboutsummaryrefslogtreecommitdiff
path: root/edit.py
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2022-05-18 10:41:01 +0900
committerA Farzat <a@farzat.xyz>2022-05-18 10:41:01 +0900
commit66ea1c1f3fe6602eee4233cd2ef10010a8a13f13 (patch)
tree4fa886f6cece44049a01ec5430d3e80a0c0a67ab /edit.py
parentc8ed1d668ed22a9bc568934eab0f4102ae9dafb6 (diff)
downloadedit-66ea1c1f3fe6602eee4233cd2ef10010a8a13f13.tar.gz
edit-66ea1c1f3fe6602eee4233cd2ef10010a8a13f13.zip
Make the editor and terminal options more flexible
This is to support tmux better. Maintains backward compatibility.
Diffstat (limited to 'edit.py')
-rw-r--r--edit.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/edit.py b/edit.py
index fe2919f..5075ddc 100644
--- a/edit.py
+++ b/edit.py
@@ -83,12 +83,15 @@ def read_file(buf):
def hook_editor_process(terminal, editor, buf):
- term_cmd = "{} -e".format(terminal)
- editor_cmd = "{} {}".format(editor, FILE)
- weechat.hook_process("{} \"{}\"".format(
- term_cmd,
- editor_cmd
- ), 0, "editor_process_cb", buf)
+ if "{}" in editor:
+ editor_cmd = editor.format(FILE)
+ else:
+ editor_cmd = "{} {}".format(editor, FILE)
+ if "{}" in terminal:
+ command = terminal.format(editor_cmd)
+ else:
+ command = "{} -e \"{}\"".format(terminal, editor_cmd)
+ weechat.hook_process(command, 0, "editor_process_cb", buf)
def run_blocking(editor, buf):