Created
July 25, 2023 13:34
-
-
Save opennomad/ffbab2393b3d166d6148f20e5a011034 to your computer and use it in GitHub Desktop.
Script to toggle the vertical size of current tmux pane to maximum
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 bash | |
# | |
# author: [email protected] | |
# inspiration from https://www.reddit.com/r/tmux/comments/7r8otc/is_there_short_command_to_expansetoggle_tmux_pane/ | |
# | |
# This script toggles the vertical size of the current tmux pane to maximum | |
# Note that the other panes in the same column will still be visible, but | |
# they will be only one line tall. | |
# | |
# Installation: | |
# Save the script as `tmux-vertical-toggle.sh` and make it executable. | |
# Then bind this in tmux to (for example) a capital Z | |
# and make sure to change the path to your chosen install path. | |
# | |
### bind-key 'Z' run "~/bin/tmux-vertical-toggle.sh" | |
# | |
# we need a statefile to bind this to a key in tmux | |
# feel free to change this | |
TMUX_VERTICAL_STATE_FILE="${HOME}/.tmux-vertical" | |
if [[ -f "${TMUX_VERTICAL_STATE_FILE}" ]]; then | |
# read the layout from the state file | |
TMVertLayout=$(<${TMUX_VERTICAL_STATE_FILE}) | |
# come back to the previous layout | |
tmux select-layout "$TMVertLayout" | |
# remove the state file | |
rm ${TMUX_VERTICAL_STATE_FILE} | |
else | |
# save the current layout | |
TMVertLayout=$(tmux list-windows |awk '$NF~/active/ {print $7}'); | |
TMVertLayout=${TMVertLayout: :-1} | |
# write the layout to the state file | |
echo ${TMVertLayout} > ${TMUX_VERTICAL_STATE_FILE} | |
# #resize the active pane height | |
tmux resize-pane -y 100 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment