Skip to content

Commit

Permalink
Make the kitty man pages automatically available inside kitty when us…
Browse files Browse the repository at this point in the history
…ing a binary build
  • Loading branch information
kovidgoyal committed Aug 19, 2022
1 parent 3288400 commit 8745c4c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 0 additions & 4 deletions docs/binary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions kitty/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:'):
Expand All @@ -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)


Expand Down

0 comments on commit 8745c4c

Please sign in to comment.