From d028139860ae06c402b14f95c204f3fe608db4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sat, 18 Sep 2021 14:16:53 +0200 Subject: [PATCH] provide optional arguments to set the path root and thetexinputs variable in edit command --- scripts/edit.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/edit.py b/scripts/edit.py index dfb708d..38c5956 100644 --- a/scripts/edit.py +++ b/scripts/edit.py @@ -2,11 +2,17 @@ import subprocess from pathlib import Path +import os -def edit(filepath: Path): +def edit(filepath: Path, rootpath: Path = None, texinputs=None): + env = dict(os.environ) + if texinputs: + env["TEXINPUTS"] = texinputs + if not rootpath: + rootpath = filepath subprocess.Popen([ "termite", "-e", f"vim --servername tex-vorlesung --remote-silent {str(filepath)}" - ]) + ], env=env, cwd=str(rootpath.root))