diff --git a/kittens/hints/main.py b/kittens/hints/main.py index e3e3e3a69..fba88370b 100644 --- a/kittens/hints/main.py +++ b/kittens/hints/main.py @@ -360,12 +360,8 @@ def load_custom_processor(customize_processing: str) -> Any: return {k: getattr(m, k) for k in dir(m)} if customize_processing == '::linenum::': return {'mark': linenum_marks, 'handle_result': linenum_handle_result} - from kitty.constants import config_dir - customize_processing = os.path.expandvars(os.path.expanduser(customize_processing)) - if os.path.isabs(customize_processing): - custom_path = customize_processing - else: - custom_path = os.path.join(config_dir, customize_processing) + from kitty.constants import resolve_custom_file + custom_path = resolve_custom_file(customize_processing) import runpy return runpy.run_path(custom_path, run_name='__main__') diff --git a/kitty/constants.py b/kitty/constants.py index 13c1e99fe..a6b4799e4 100644 --- a/kitty/constants.py +++ b/kitty/constants.py @@ -198,3 +198,10 @@ def running_in_kitty(set_val: Optional[bool] = None) -> bool: if set_val is not None: setattr(running_in_kitty, 'ans', set_val) return bool(getattr(running_in_kitty, 'ans', False)) + + +def resolve_custom_file(path: str) -> str: + path = os.path.expandvars(os.path.expanduser(path)) + if not os.path.isabs(path): + path = os.path.join(config_dir, path) + return path