Created
October 25, 2022 22:40
-
-
Save vsinha/62e8bb9d5b38c3aa5c5eb0add9e481c6 to your computer and use it in GitHub Desktop.
kitty relative_resize.py
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 | |
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