Skip to content

Instantly share code, notes, and snippets.

@geky
Last active December 8, 2021 23:44
Show Gist options
  • Save geky/d6dda1160b5719dd155b1b91b48bfd6e to your computer and use it in GitHub Desktop.
Save geky/d6dda1160b5719dd155b1b91b48bfd6e to your computer and use it in GitHub Desktop.
Fixed the height of panes even when the window resizes
#!/bin/bash
#
# example:
# ./tmux-fixh.sh -g top-right 7
if [ "$#" -lt 2 ] && [ "$1" != "-u" ]
then
echo "usage: $0 [-gu] <pane> <height>"
exit 1
fi
if [ "$1" == "-g" ]
then
echo "tmux set-hook -g window-layout-changed \"run-shell '$0 $2 $3'\""
tmux set-hook -g window-layout-changed "run-shell '$0 $2 $3'"
elif [ "$1" == "-u" ]
then
echo "tmux set-hook -gu window-layout-changed"
tmux set-hook -gu window-layout-changed
else
# zoomed?
z=$(tmux list-panes -F '#F' | grep -o -m1 'Z')
# height changed?
h=$(tmux display-message -p -t "$1" '#{pane_height}')
if [ "$z" != 'Z' ] && [ "$h" != "$2" ]
then
tmux resize-pane -t "$1" -y "$2"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment