Last active
December 8, 2021 23:44
-
-
Save geky/d6dda1160b5719dd155b1b91b48bfd6e to your computer and use it in GitHub Desktop.
Fixed the height of panes even when the window resizes
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
#!/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