From 1ded78a98c87f953df2c49089265eaba50865da9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 3 Mar 2021 16:04:08 +0530 Subject: [PATCH] A new command to show the env vars of the kitty process --- docs/faq.rst | 15 +++++++++++---- kitty/boss.py | 8 +++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index 657f9953d..f60855518 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -270,10 +270,17 @@ and the shell's rc files will have setup a whole different set of environment variables which kitty will now inherit. You need to make sure that the environment variables you define in your shell's -rc files are either also defined system wide or via the ``env`` directive in -kitty.conf. Common environment variables that cause issues are those related to -localization, such as ``LANG, LC_*`` and loading of configuration files such as -``XDG_*, KITTY_CONFIG_DIRECTORY``. +rc files are either also defined system wide or via the :opt:`env` directive in +:file:`kitty.conf`. Common environment variables that cause issues are those +related to localization, such as ``LANG, LC_*`` and loading of configuration +files such as ``XDG_*, KITTY_CONFIG_DIRECTORY``. + +To see the environment variables that kitty sees, you can add the following +mapping to :file:`kitty.conf`:: + + map f1 show_kitty_env_vars + +then pressing :kbd:`F1` will show you the environment variables kitty sees. This problem is most common on macOS, as Apple makes it exceedingly difficult to setup environment variables system-wide, so people end up putting them in all diff --git a/kitty/boss.py b/kitty/boss.py index b261ddf59..e5572fb4b 100755 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -853,7 +853,7 @@ class Boss: s.shutdown(socket.SHUT_RDWR) s.close() - def display_scrollback(self, window: Window, data: Optional[bytes], cmd: Optional[List[str]]) -> None: + def display_scrollback(self, window: Window, data: Optional[bytes], cmd: List[str]) -> None: tab = self.active_tab if tab is not None: tab.new_special_window( @@ -1635,3 +1635,9 @@ class Boss: self.set_active_window(w, switch_os_window_if_needed=True) if report: w.report_notification_activated(identifier) + + def show_kitty_env_vars(self) -> None: + w = self.active_window + if w: + output = '\n'.join(f'{k}={v}' for k, v in os.environ.items()).encode('utf-8') + self.display_scrollback(w, output, ['less'])