From 88f25ccc7671d0b71cd71a499bcdd5c6e0a07d86 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 22 Jul 2019 10:30:11 +0530 Subject: [PATCH] Also handle non-absolute paths being used for $EDITOR --- kitty/main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kitty/main.py b/kitty/main.py index a6fc26dcf..5a5c3af40 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -226,7 +226,18 @@ def setup_environment(opts, args): if 'EDITOR' not in os.environ: shell_env = read_shell_environment(opts) if 'EDITOR' in shell_env: - os.environ['EDITOR'] = shell_env['EDITOR'] + editor = shell_env['EDITOR'] + if 'PATH' in shell_env: + import shlex + editor_cmd = shlex.split(editor) + if not os.path.isabs(editor_cmd[0]): + editor_cmd[0] = shutil.which(editor_cmd[0], path=shell_env['PATH']) + if editor_cmd[0]: + editor = ' '.join(map(shlex.quote, editor_cmd)) + else: + editor = None + if editor: + os.environ['EDITOR'] = editor else: os.environ['EDITOR'] = opts.editor if args.listen_on: