├── .gitignore ├── README.md ├── pane-menu.tmux ├── screenshots └── pane-menu.png └── source ├── layout-submenu.sh ├── menu.sh └── send-to-window-submenu.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .*.swp 3 | .*.swo 4 | .*.swn 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tmux-pane-menu :-) 2 | 3 | A tmux menu to expose some of the functionality surrounding panes in tmux. It's 4 | the kind of thing that will help reduce the amount of tmux prefix shortcuts you 5 | have to remember and/or configure. 6 | 7 | ## What it can do 8 | We have some basic stuff to begin with: 9 | 10 | * Zoom pane to maximie the pane you're currently using. 11 | * Show a clock in a pane (neat party trick lol, and good for being mindful 12 | about the time when getting lost in having fun). 13 | * Kill a pane if/when for whatever reason it stops responding. 14 | 15 | ### Split 16 | You have your normal way of doing splits and maybe your abnormal ones: 17 | 18 | * Split horizontal (a pane is split down the middle) 19 | * Split vertical (a pane is split across) 20 | * Create new splits above or below in full width. 21 | * Create splits to the left or right in full height. 22 | 23 | ### Navigate 24 | Of course you can also navigate between panes with this little menu. The menu 25 | will stay on screen while you navigate so it's easy to quickly navigate once you 26 | have begun. You can also: 27 | 28 | * Navigate to a pane in a visual way. 29 | * Navigate the last active pane. 30 | 31 | ### Resize 32 | Get all your resizing done with this menu with w, a, s, d keys and feel like a 33 | million bucks. 34 | 35 | ### Rearrange 36 | Rotate your panes, swap them, break them put into new windows, send them to 37 | existing windows or use layout prefixes :-) 38 | 39 | ## What it looks like 40 | 41 | ![main](/screenshots/pane-menu.png) 42 | 43 | ## How to install it 44 | Use [TPM](https://github.com/tmux-plugins/tpm) for a smooth experience. Add 45 | this to your tmux.conf: 46 | 47 | ``` 48 | set -g @plugin 'datamadsen/tmux-pane-menu' 49 | ``` 50 | 51 | Then hit `prefix + I` and you're good to go. Use `prefix + U` from time to time 52 | to update plugins managed by TPM. 53 | 54 | ## How to invoke it 55 | By default the menu is invoked with `prefix + p` (p for pane), but you can 56 | change it like this in your tmux.conf: 57 | 58 | ``` 59 | set -g @pane_menu_trigger 'a' 60 | ``` 61 | 62 | If you want to invoke it without tmux' prefix, e.g. with `Ctrl-P`, you can 63 | configure that like this: 64 | 65 | ``` 66 | set -g @pane_menu_trigger 'C-p' 67 | ``` 68 | -------------------------------------------------------------------------------- /pane-menu.tmux: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | trigger=$(tmux show-options -gv "@pane_menu_trigger") 6 | 7 | if [ -z "$trigger" ]; then 8 | trigger="p" 9 | fi 10 | 11 | if [[ $trigger == *"-"* ]]; then 12 | tmux bind -n $trigger run-shell $CURRENT_DIR/source/menu.sh 13 | else 14 | tmux bind $trigger run-shell $CURRENT_DIR/source/menu.sh 15 | fi 16 | -------------------------------------------------------------------------------- /screenshots/pane-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datamadsen/tmux-pane-menu/3906217a0c58b1f226f6eb929da8db2080a2ed90/screenshots/pane-menu.png -------------------------------------------------------------------------------- /source/layout-submenu.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | menu_items=( 6 | "'#{?#{>:#{window_panes},1},,-}Main-vertical' '<' 'select-layout main-vertical'" 7 | "'#{?#{>:#{window_panes},1},,-}Main-horizontal' '>' 'select-layout main-horizontal'" 8 | "'#{?#{>:#{window_panes},1},,-}Even-vertical' ',' 'select-layout even-vertical'" 9 | "'#{?#{>:#{window_panes},1},,-}Even-horizontal' '.' 'select-layout even-horizontal'" 10 | "'#{?#{>:#{window_panes},1},,-}Tile' 't' 'select-layout tiled'" 11 | "'#{?#{>:#{window_panes},1},,-}Previous' 'p' 'select-layout -o'" 12 | ) 13 | 14 | printf '%s\n' "${menu_items[@]}" \ 15 | | xargs tmux display-menu \ 16 | -T "#[align=centre] layouts :-) " 17 | 18 | -------------------------------------------------------------------------------- /source/menu.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | menu_items=( 6 | "'#{?#{>:#{window_panes},1},,-}#{?#{window_zoomed_flag},Un-Zoom,Zoom}' z 'resize-pane -Z'" 7 | '"Clock" c "clock-mode"' 8 | '"Kill" x "kill-pane"' 9 | '"-~~~~~~~~~~~~~~~~~~~~~~~ Split" "" ""' 10 | '"Horizontal" \\ "split-window -h -c #{pane_current_path}"' 11 | '"Vertical" - "split-window -v -c #{pane_current_path}"' 12 | '"Above in full width" + "split-window -bf -c #{pane_current_path}"' 13 | '"Below in full width" _ "split-window -fv -c #{pane_current_path}"' 14 | '"Left in full height" < "split-window -fhb -c #{pane_current_path}"' 15 | '"Right in full height" > "split-window -fh -c #{pane_current_path}"' 16 | '"-~~~~~~~~~~~~~~~~~~~~ Navigate" "" ""' 17 | "'#{?#{>:#{window_panes},1},,-}Visual...' v 'run-shell \"tmux display-panes -d0\"'" 18 | "'#{?#{>:#{window_panes},1},,-}Last active' l 'last-pane'" 19 | "'#{?#{>:#{window_panes},1},,-}Up' 'up' 'run-shell \"tmux select-pane -U && $CURRENT_DIR/menu.sh\"'" 20 | "'#{?#{>:#{window_panes},1},,-}Left' 'left' 'run-shell \"tmux select-pane -L && $CURRENT_DIR/menu.sh\"'" 21 | "'#{?#{>:#{window_panes},1},,-}Down' 'down' 'run-shell \"tmux select-pane -D && $CURRENT_DIR/menu.sh\"'" 22 | "'#{?#{>:#{window_panes},1},,-}Right' 'right' 'run-shell \"tmux select-pane -R && $CURRENT_DIR/menu.sh\"'" 23 | 24 | '"-~~~~~~~~~~~~~~~~~~~~~~ Resize" "" ""' 25 | "'#{?#{>:#{window_panes},1},,-}Up' w 'run-shell \"tmux resize-pane -U 5 && $CURRENT_DIR/menu.sh\"'" 26 | "'#{?#{>:#{window_panes},1},,-}Left' a 'run-shell \"tmux resize-pane -L 5 && $CURRENT_DIR/menu.sh\"'" 27 | "'#{?#{>:#{window_panes},1},,-}Down' s 'run-shell \"tmux resize-pane -D 5 && $CURRENT_DIR/menu.sh\"'" 28 | "'#{?#{>:#{window_panes},1},,-}Right' d 'run-shell \"tmux resize-pane -R 5 && $CURRENT_DIR/menu.sh\"'" 29 | 30 | '"-~~~~~~~~~~~~~~~~~~~ Rearrange" "" ""' 31 | "'#{?#{>:#{window_panes},1},,-}Rotate up' [ 'run-shell \"tmux swap-pane -U && $CURRENT_DIR/menu.sh\"'" 32 | "'#{?#{>:#{window_panes},1},,-}Rotate down' ] 'run-shell \"tmux swap-pane -D && $CURRENT_DIR/menu.sh\"'" 33 | '"#{?#{>:#{window_panes},1},,-}Break to window" n "break-pane"' 34 | "'#{?#{>:#{window_panes},1},,-}Swap visual...' 0 'display-panes -d0 \"swap-pane -t '%%' -d\"'" 35 | "'#{?#{>:#{window_panes},1},,-}Layout prefixes...' '=' 'run-shell \"$CURRENT_DIR/layout-submenu.sh\"'" 36 | "'#{?#{>:#{session_windows},1},,-}Send to window...' '|' 'run-shell \"$CURRENT_DIR/send-to-window-submenu.sh\"'" 37 | ) 38 | 39 | printf '%s\n' "${menu_items[@]}" \ 40 | | xargs tmux display-menu \ 41 | -T "#[align=centre] pane menu :-) " \ 42 | -------------------------------------------------------------------------------- /source/send-to-window-submenu.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | menu_items=( 6 | '"" "" ""' 7 | ) 8 | 9 | IFS='!' 10 | 11 | join_to_window_items=$(tmux list-windows -F '"#{?#{==:#{window_active},1},-,}#{window_index} #{window_name} #{?#{==:#{window_active},1},(this window),}" #{window_index} "join-pane -t :#{window_index}"!' ) 12 | 13 | for item in $join_to_window_items 14 | do 15 | menu_items+=(${item}) 16 | done 17 | 18 | printf '%s\n' "${menu_items[@]}" \ 19 | | xargs tmux display-menu \ 20 | -T "#[align=centre] send to window :-) " 21 | --------------------------------------------------------------------------------