Avoid unnecessary which and fix typos

This commit is contained in:
pagedown
2022-03-07 11:30:12 +08:00
parent 3095e7a256
commit 397fbe7ad3
3 changed files with 14 additions and 15 deletions

View File

@@ -103,21 +103,20 @@ def move(src, base_dest):
def compile_terminfo(base):
if not shutil.which('tic'):
tic = shutil.which('tic')
if not tic:
return
tname = '.terminfo'
if os.path.exists('/usr/share/misc/terminfo.cdb'):
tname += '.cdb'
os.environ['TERMINFO'] = os.path.join(HOME, tname)
tic = shutil.which('tic')
if tic:
cp = subprocess.run(
[tic, '-x', '-o', os.path.join(base, tname), os.path.join(base, '.terminfo', 'kitty.terminfo')],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
if cp.returncode != 0:
sys.stderr.buffer.write(cp.stdout)
raise SystemExit('Failed to compile the terminfo database')
cp = subprocess.run(
[tic, '-x', '-o', os.path.join(base, tname), os.path.join(base, '.terminfo', 'kitty.terminfo')],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
if cp.returncode != 0:
sys.stderr.buffer.write(cp.stdout)
raise SystemExit('Failed to compile the terminfo database')
def get_data():
@@ -176,8 +175,8 @@ def exec_zsh_with_integration():
os.environ.pop('KITTY_ORIG_ZDOTDIR', None) # ensure this is not propagated
else:
os.environ['KITTY_ORIG_ZDOTDIR'] = zdotdir
# dont prevent zsh-new-user from running
for q in '.zshrc .zshenv .zprofile .zlogin'.split():
# dont prevent zsh-newuser-install from running
for q in ('.zshrc', '.zshenv', '.zprofile', '.zlogin'):
if os.path.exists(os.path.join(HOME, q)):
os.environ['ZDOTDIR'] = shell_integration_dir + '/zsh'
os.execlp(login_shell, os.path.basename(login_shell), '-l')