From 28ae8c4d2057f0f121e3e3021baa324f7fc756e5 Mon Sep 17 00:00:00 2001 From: pagedown Date: Tue, 26 Jul 2022 13:21:50 +0800 Subject: [PATCH] Expand ~ when resolving editor path and applying exe_search_path --- docs/changelog.rst | 2 ++ kitty/utils.py | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 588e6834d..095326a13 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -82,6 +82,8 @@ Detailed list of changes - remote files kitten: Fix working with files whose names have characters that need to be quoted in shell scripts (:iss:`5313`) +- Expand ~ in paths configured in :opt:`editor` and :opt:`exe_search_path` (:disc:`5298`) + 0.25.2 [2022-06-07] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/utils.py b/kitty/utils.py index 6fd7ec9e0..45ae70e50 100644 --- a/kitty/utils.py +++ b/kitty/utils.py @@ -670,6 +670,7 @@ def get_editor(opts: Optional[Options] = None, path_to_edit: str = '', line_numb else: import shlex ans = shlex.split(opts.editor) + ans[0] = os.path.expanduser(ans[0]) if path_to_edit: if line_number: eq = os.path.basename(ans[0]).lower() @@ -778,11 +779,11 @@ def which(name: str, only_system: bool = False) -> Optional[str]: x = x.strip() if x: if x[0] == '-': - tried_paths.add(x[1:]) + tried_paths.add(os.path.expanduser(x[1:])) elif x[0] == '+': - append_paths.append(x[1:]) + append_paths.append(os.path.expanduser(x[1:])) else: - paths.append(x) + paths.append(os.path.expanduser(x)) ep = os.environ.get('PATH') if ep: paths.extend(ep.split(os.pathsep))