Make the kitty man pages automatically available inside kitty when using a binary build

This commit is contained in:
Kovid Goyal 2022-08-19 12:59:10 +05:30
parent 3288400005
commit 8745c4cd4a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 4 deletions

View File

@ -56,10 +56,6 @@ particular desktop, but it should work for most major desktop environments.
# Update the paths to the kitty and its icon in the kitty.desktop file(s)
sed -i "s|Icon=kitty|Icon=/home/$USER/.local/kitty.app/share/icons/hicolor/256x256/apps/kitty.png|g" ~/.local/share/applications/kitty*.desktop
sed -i "s|Exec=kitty|Exec=/home/$USER/.local/kitty.app/bin/kitty|g" ~/.local/share/applications/kitty*.desktop
# Install the man pages
mkdir -p ~/.local/share/man/man1 ~/.local/share/man/man5
ln -s ~/.local/kitty.app/share/man/man1/kitty.1 ~/.local/share/man/man1
ln -s ~/.local/kitty.app/share/man/man5/kitty.conf.5 ~/.local/share/man/man5
.. note::
In :file:`kitty-open.desktop`, kitty is registered to handle some supported

View File

@ -318,6 +318,22 @@ def ensure_kitty_in_path() -> None:
os.environ['PATH'] = prepend_if_not_present(rpath, env_path)
def setup_manpath(env: Dict[str, str]) -> None:
# Ensure kitty manpages are available in frozen builds
if not getattr(sys, 'frozen', False):
return
from .constants import local_docs
mp = os.environ.get('MANPATH', env.get('MANPATH', ''))
d = os.path.dirname
kitty_man = os.path.join(d(d(d(local_docs()))), 'man')
if not mp:
env['MANPATH'] = f'{kitty_man}:'
elif mp.startswith(':'):
env['MANPATH'] = f':{kitty_man}:{mp}'
else:
env['MANPATH'] = f'{kitty_man}:{mp}'
def setup_environment(opts: Options, cli_opts: CLIOptions) -> None:
from_config_file = False
if not cli_opts.listen_on and opts.listen_on.startswith('unix:'):
@ -334,6 +350,7 @@ def setup_environment(opts: Options, cli_opts: CLIOptions) -> None:
# the other values mean the user doesn't want a PATH
if child_path not in ('', DELETE_ENV_VAR) and child_path is not None:
env['PATH'] = prepend_if_not_present(os.path.dirname(kitty_path), env['PATH'])
setup_manpath(env)
set_default_env(env)