Skip to content

Instantly share code, notes, and snippets.

@brettbuddin
Created April 27, 2023 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettbuddin/f9d1b065d89f8333b0c49130f6bfdc6b to your computer and use it in GitHub Desktop.
Save brettbuddin/f9d1b065d89f8333b0c49130f6bfdc6b to your computer and use it in GitHub Desktop.
Stack-based windowing in tmux.
# Create new pane in current directory
bind -n M-c split-window -b -t :.0 -c "#{pane_current_path}" \;\
select-layout main-vertical \;\
run "tmux resize-pane -t :.0 -x 50%"
# Kill pane (only kill if we have more than one pane)
TMUX_SHOULD_KILL_PANE="tmux display-message -p '#{window_panes}' | awk '{exit(!($0>1))}'"
bind -n M-x if-shell "$TMUX_SHOULD_KILL_PANE" \
"kill-pane -t :." \;\
select-layout main-vertical \;\
run "tmux resize-pane -t :.0 -x 50%" \;\
select-pane -t :.0
# Next pane
bind -n M-j select-pane -t :.+
# Prev pane
bind -n M-k select-pane -t :.-
# Rotate counterclockwise
bind -n M-, rotate-window -U \; select-pane -t 0
# Rotate clockwise
bind -n M-. rotate-window -D \; select-pane -t 0
# Focus selected pane
bind -n M-Space swap-pane -s :. -t :.0 \; select-pane -t :.0
# Refresh layout
bind -n M-r select-layout main-vertical \;\
run "tmux resize-pane -t :.0 -x 50%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment