Skip to content

Instantly share code, notes, and snippets.

@vsinha
Created October 25, 2022 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsinha/62e8bb9d5b38c3aa5c5eb0add9e481c6 to your computer and use it in GitHub Desktop.
Save vsinha/62e8bb9d5b38c3aa5c5eb0add9e481c6 to your computer and use it in GitHub Desktop.
kitty relative_resize.py
#!/usr/bin/env python3
from kittens.tui.handler import result_handler
def main(args):
pass
@result_handler(no_ui=True)
def handle_result(args, result, target_window_id, boss):
window = boss.window_id_map.get(target_window_id)
if window is None:
return
direction = args[1]
amount = 1
if len(args) > 1:
amount = int(args[2])
neighbor_direction = direction
if direction == "up":
neighbor_direction = "top"
if direction == "down":
neighbor_direction = "bottom"
neighbor = boss.active_tab.neighboring_group_id(neighbor_direction)
if direction == "left" or direction == "right":
if neighbor is None:
boss.active_tab.resize_window("narrower", amount)
else:
boss.active_tab.resize_window("wider", amount)
return
if direction == "up" or direction == "down":
if neighbor is None:
boss.active_tab.resize_window("shorter", amount)
else:
boss.active_tab.resize_window("taller", amount)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment