When running kitty from within kitty, use a full path

Fixes inability to run kitty from the shell when the users shell scripts
reset PATH. See #668
This commit is contained in:
Kovid Goyal
2018-06-22 15:33:07 +05:30
parent 82f6fbff77
commit aba84581f5
4 changed files with 25 additions and 14 deletions

View File

@@ -21,6 +21,22 @@ ScreenGeometry = namedtuple('ScreenGeometry', 'xstart ystart xnum ynum dx dy')
WindowGeometry = namedtuple('WindowGeometry', 'left top right bottom xnum ynum')
def kitty_exe():
ans = getattr(kitty_exe, 'ans', None)
if ans is None:
rpath = getattr(sys, 'bundle_exe_dir', None)
items = frozenset(os.environ['PATH'].split(os.pathsep))
if not rpath:
for candidate in items:
if os.access(os.path.join(candidate, 'kitty'), os.X_OK):
rpath = candidate
break
else:
rpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'launcher')
ans = kitty_exe.ans = os.path.join(rpath, 'kitty')
return ans
def _get_config_dir():
if 'KITTY_CONFIG_DIRECTORY' in os.environ:
return os.path.abspath(os.path.expanduser(os.environ['KITTY_CONFIG_DIRECTORY']))