Last active
November 16, 2022 09:25
-
-
Save yyogo/4b47c149c2fe6dfb5e9c2e1d6bc21523 to your computer and use it in GitHub Desktop.
iTerm 2 unzoom on switch pane script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.7 | |
# Put this script in ~/.config/iterm/Scripts or whatever, then enable in the Scripts menu | |
# Map switch keys to "Invoke Script Function...": `unzoom_and_switch(direction: "above/below/left/right")` | |
import iterm2 | |
async def async_turn_off_menu_option(conn: iterm2.Connection, option: str): | |
state = await iterm2.MainMenu.async_get_menu_item_state(conn, option) | |
if state.checked: | |
await iterm2.MainMenu.async_select_menu_item(conn, option) | |
async def main(conn: iterm2.Connection): | |
app = await iterm2.async_get_app(conn) | |
@iterm2.RPC | |
async def unzoom_and_switch(direction: str): | |
window = app.current_window | |
tab = window.current_tab | |
await async_turn_off_menu_option(conn, 'Maximize Active Pane') | |
await tab.async_select_pane_in_direction(iterm2.NavigationDirection(direction)) | |
await unzoom_and_switch.async_register(conn) | |
iterm2.run_forever(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment