From 6cba512c01f7bb19ff002489cb3af43ed2f1712d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 1 May 2022 21:07:15 +0200 Subject: [PATCH] add editor into config --- scripts/parse_config.py | 12 +++++++++++- scripts/window_subprocess.py | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/parse_config.py b/scripts/parse_config.py index 9a6b9c1..c3a383d 100644 --- a/scripts/parse_config.py +++ b/scripts/parse_config.py @@ -21,7 +21,9 @@ def get_config_file(): '# Edit this as you wish\n' '\n' '[Subprocess]\n' - 'terminal = i3-sensible-terminal' + 'terminal = i3-sensible-terminal\n' + 'editor = vim\n' + '' ) print(f'Initialized default config file at {str(config_file)}.') print(config_file) @@ -43,3 +45,11 @@ def terminal() -> str: return d['terminal'] else: return 'i3-sensible-terminal' + + +def editor() -> str: + d = get_config('Subprocess') + if 'editor' in d.keys(): + return d['editor'] + else: + return 'vim' \ No newline at end of file diff --git a/scripts/window_subprocess.py b/scripts/window_subprocess.py index e6636d2..44a184c 100644 --- a/scripts/window_subprocess.py +++ b/scripts/window_subprocess.py @@ -4,7 +4,7 @@ import subprocess from pathlib import Path import os -from parse_config import terminal +from parse_config import terminal, editor def edit(filepath: Path, rootpath: Path = None, env=os.environ, servername='tex lecture'): @@ -13,7 +13,7 @@ def edit(filepath: Path, rootpath: Path = None, env=os.environ, servername='tex subprocess.Popen([ terminal(), "-e", - f"vim", + editor(), f"--servername {servername}", f"--remote-silent", f"{str(filepath)}"