11/10/2023 0 Comments Iterm2 themes![]() # Set preset if theme has changed await ast. # Block until theme changes theme = await mon. ![]() get_event_loop())Īst = AutoSwtichTheme( connection, THEME_LIGHT, THEME_DARK)Īwait ast. ensure_future( quit( connection), loop = asyncio. Return "" async def set_color_preset( self, theme): #!/usr/bin/env python3 import asyncio import iterm2 THEME_LIGHT = "Tango Light" THEME_DARK = "Tango Dark" class AutoSwtichTheme:ĭef _init_( self, connection, light = "Light Background", dark = "Dark Background"): It seems does not work anymore, i got the error message "auto_dark_mode" ended unexpectedly # Themes have space-delimited attributes, one of which will be light or dark. iTerm2 brings the terminal into the modern age with features you never knew you always wanted. It works on Macs with macOS 10.14 or newer. Go back to iTerm2, go to Scripts in the menu bar and select the script you just saved. Copy and paste the script below and save. Give the script a decent name (I chose autodarkmode.py) Save and open the script in your editor of choice. Initial_theme = await app.async_get_theme()Īwait changeTheme(connection,initial_theme)Īsync with iterm2.VariableMonitor(connection,, "effectiveTheme", None) as mon: Download and install iTerms2 from here iTerm2 is a replacement for Terminal and the successor to iTerm. In iTerm2, in the menu bar go to Scripts > Manage > New Python Script. Profile = await partial.async_get_full_profile()Īwait profile.async_set_color_preset(preset)Īpp = await iterm2.async_get_app(connection) # Fetch the full profile and then set the color preset in it. # Update the list of all profiles and iterate over them. Preset = await _get(connection, theme_light) Preset = await _get(connection, theme_dark) I cleaned up your script so it's easier to maintain :) #!/usr/bin/env python3 I personally use Solarized Dark and Solarized Light Not the most elegant code as I am not very familiar with Python asyncĮdit: Make sure the theme is the same as your usual theme (Preferences > Profiles > Colors > Color Presets.). I tweaked it to also check if the theme is correct at iTem2 startup.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |