Add get_window_size()
This commit is contained in:
parent
ba69773fba
commit
4c76e59238
1 changed files with 23 additions and 9 deletions
|
|
@ -127,6 +127,20 @@ def get_pane_size(pane_id=None):
|
||||||
return (width, height)
|
return (width, height)
|
||||||
|
|
||||||
|
|
||||||
|
def get_window_size():
|
||||||
|
"""Get current window size, returns tuple."""
|
||||||
|
cmd = ['tmux', 'display', '-p', '#{window_width} #{window_height}']
|
||||||
|
|
||||||
|
# Get resolution
|
||||||
|
proc = run_program(cmd, check=False)
|
||||||
|
width, height = proc.stdout.strip().split()
|
||||||
|
width = int(width)
|
||||||
|
height = int(height)
|
||||||
|
|
||||||
|
# Done
|
||||||
|
return (width, height)
|
||||||
|
|
||||||
|
|
||||||
def kill_all_panes(pane_id=None):
|
def kill_all_panes(pane_id=None):
|
||||||
"""Kill all panes except for the current or target pane."""
|
"""Kill all panes except for the current or target pane."""
|
||||||
cmd = ['tmux', 'kill-pane', '-a']
|
cmd = ['tmux', 'kill-pane', '-a']
|
||||||
|
|
@ -273,6 +287,15 @@ def resize_pane(pane_id=None, width=None, height=None, **kwargs):
|
||||||
run_program(cmd, check=False)
|
run_program(cmd, check=False)
|
||||||
|
|
||||||
|
|
||||||
|
def respawn_pane(pane_id, **action):
|
||||||
|
"""Respawn pane with action."""
|
||||||
|
cmd = ['tmux', 'respawn-pane', '-k', '-t', pane_id]
|
||||||
|
cmd.extend(prep_action(**action))
|
||||||
|
|
||||||
|
# Respawn
|
||||||
|
run_program(cmd, check=False)
|
||||||
|
|
||||||
|
|
||||||
def split_window(
|
def split_window(
|
||||||
lines=None, percent=None,
|
lines=None, percent=None,
|
||||||
behind=False, vertical=False,
|
behind=False, vertical=False,
|
||||||
|
|
@ -309,15 +332,6 @@ def split_window(
|
||||||
return proc.stdout.strip()
|
return proc.stdout.strip()
|
||||||
|
|
||||||
|
|
||||||
def respawn_pane(pane_id, **action):
|
|
||||||
"""Respawn pane with action."""
|
|
||||||
cmd = ['tmux', 'respawn-pane', '-k', '-t', pane_id]
|
|
||||||
cmd.extend(prep_action(**action))
|
|
||||||
|
|
||||||
# Respawn
|
|
||||||
run_program(cmd, check=False)
|
|
||||||
|
|
||||||
|
|
||||||
def zoom_pane(pane_id=None):
|
def zoom_pane(pane_id=None):
|
||||||
"""Toggle zoom status for current or target pane."""
|
"""Toggle zoom status for current or target pane."""
|
||||||
cmd = ['tmux', 'resize-pane', '-Z']
|
cmd = ['tmux', 'resize-pane', '-Z']
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue