├── .gitattributes
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── pain_control.tmux
└── screenshots
├── pane_navigation.gif
├── pane_resizing.gif
├── pane_resizing.psd
├── pane_splitting.gif
└── pane_splitting.psd
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Force text files to have unix eols, so Windows/Cygwin does not break them
2 | *.* eol=lf
3 |
4 | *.gif binary
5 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ### master
4 | - update readme - write all keybindings
5 | - override default split window key bindings
6 | - Moving windows follows current window, compensate for change in behavior in
7 | tmux 3.0
8 |
9 | ### v1.0.0, 2014-08-30
10 | - update readme to reflect github organization change
11 | - update readme - more precise binding definition
12 | - switch to tab indentation
13 | - add swap-window bindings
14 | - change "move window" key bindings to be more intuitive
15 |
16 | ### v0.0.2, 2014-06-03
17 | - split-window bindings "|" and "-" now create a new pane with the same path as
18 | the original one the split started from.
19 | - improve the default new-window "c" binding so it creates new windows with the
20 | same path as the current pane
21 | - bugfix for "|", "-" and "c" bindings - setting the correct path in new windows
22 | wasn't working properly with "$PWD". Changed to "#{pane_current_path}".
23 | - add other plugins list to the README
24 |
25 | ### v0.0.1, 2014-05-23
26 | - first version out
27 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (C) 2014 Bruno Sutic
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the "Software"),
5 | to deal in the Software without restriction, including without limitation
6 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 | and/or sell copies of the Software, and to permit persons to whom the
8 | Software is furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included
11 | in all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
19 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tmux Pain Control
2 |
3 | Tmux plugin for controlling panes. Adds standard pane navigation bindings.
4 |
5 | So far, you had to google around and comb other people's dotfiles to find these.
6 | This plugin hopefully makes them more available and "more standard".
7 |
8 | Thanks to the Tmux community for "inventing" these bindings. I've merely just
9 | copied them here.
10 |
11 | Tested and working on Linux, OSX and Cygwin.
12 |
13 | ### Bindings
14 |
15 | Notice most of the bindings emulate vim cursor movements.
16 |
17 |
18 |
19 | **Navigation**
20 |
21 | - `prefix + h` and `prefix + C-h`
22 | select pane on the left
23 | - `prefix + j` and `prefix + C-j`
24 | select pane below the current one
25 | - `prefix + k` and `prefix + C-k`
26 | select pane above
27 | - `prefix + l` and `prefix + C-l`
28 | select pane on the right
29 |
30 |
31 |
32 | **Note**: This overrides tmux's default binding for toggling between last
33 | active windows, `prefix + l`.
34 | [tmux-sensible](https://github.com/tmux-plugins/tmux-sensible) gives you
35 | a better binding for that, `prefix + a` (if your prefix is `C-a`).
36 |
37 |
38 |
39 |
40 |
41 | **Resizing panes**
42 |
43 | - `prefix + shift + h`
44 | resize current pane 5 cells to the left
45 | - `prefix + shift + j`
46 | resize 5 cells in the down direction
47 | - `prefix + shift + k`
48 | resize 5 cells in the up direction
49 | - `prefix + shift + l`
50 | resize 5 cells to the right
51 |
52 | These mappings are `repeatable`.
53 |
54 | The amount of cells to resize can be configured with `@pane_resize` option. See
55 | [configuration section](#configuration) for the details.
56 |
57 |
58 |
59 |
60 |
61 | **Splitting panes**
62 |
63 | - `prefix + |`
64 | split the current pane into two, left and right.
65 | - `prefix + -`
66 | split the current pane into two, top and bottom.
67 | - `prefix + \`
68 | split current pane full width into two, left and right.
69 | - `prefix + _`
70 | split current pane full height into two, top and bottom.
71 |
72 | Newly created pane always has the same path as the original pane.
73 |
74 |
75 |
76 | **Swapping windows**
77 |
78 | - `prefix + <` - moves current window one position to the left
79 | - `prefix + >` - moves current window one position to the right
80 |
81 | ### Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended)
82 |
83 | Add plugin to the list of TPM plugins in `.tmux.conf`:
84 |
85 | set -g @plugin 'tmux-plugins/tmux-pain-control'
86 |
87 | Hit `prefix + I` to fetch the plugin and source it.
88 |
89 | You should now have all `pain-control` bindings defined.
90 |
91 | ### Manual Installation
92 |
93 | Clone the repo:
94 |
95 | $ git clone https://github.com/tmux-plugins/tmux-pain-control ~/clone/path
96 |
97 | Add this line to the bottom of `.tmux.conf`:
98 |
99 | run-shell ~/clone/path/pain_control.tmux
100 |
101 | Reload TMUX environment:
102 |
103 | # type this in terminal
104 | $ tmux source-file ~/.tmux.conf
105 |
106 | You should now have all `pain-control` bindings defined.
107 |
108 | ### Configuration
109 |
110 | You can set `@pane_resize` Tmux option to choose number of resize cells for the
111 | resize bindings. "5" is the default.
112 |
113 | Example:
114 |
115 | set-option -g @pane_resize "10"
116 |
117 | ### Other plugins
118 |
119 | You might also find these useful:
120 |
121 | - [sessionist](https://github.com/tmux-plugins/tmux-sessionist) - lightweight
122 | tmux utils for switching and creating sessions
123 | - [logging](https://github.com/tmux-plugins/tmux-logging) - easy logging and
124 | screen capturing
125 |
126 | ### License
127 | [MIT](LICENSE.md)
128 |
--------------------------------------------------------------------------------
/pain_control.tmux:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | default_pane_resize="5"
4 |
5 | # tmux show-option "q" (quiet) flag does not set return value to 1, even though
6 | # the option does not exist. This function patches that.
7 | get_tmux_option() {
8 | local option=$1
9 | local default_value=$2
10 | local option_value=$(tmux show-option -gqv "$option")
11 | if [ -z $option_value ]; then
12 | echo $default_value
13 | else
14 | echo $option_value
15 | fi
16 | }
17 |
18 | pane_navigation_bindings() {
19 | tmux bind-key h select-pane -L
20 | tmux bind-key C-h select-pane -L
21 | tmux bind-key j select-pane -D
22 | tmux bind-key C-j select-pane -D
23 | tmux bind-key k select-pane -U
24 | tmux bind-key C-k select-pane -U
25 | tmux bind-key l select-pane -R
26 | tmux bind-key C-l select-pane -R
27 | }
28 |
29 | window_move_bindings() {
30 | tmux bind-key -r "<" swap-window -d -t -1
31 | tmux bind-key -r ">" swap-window -d -t +1
32 | }
33 |
34 | pane_resizing_bindings() {
35 | local pane_resize=$(get_tmux_option "@pane_resize" "$default_pane_resize")
36 | tmux bind-key -r H resize-pane -L "$pane_resize"
37 | tmux bind-key -r J resize-pane -D "$pane_resize"
38 | tmux bind-key -r K resize-pane -U "$pane_resize"
39 | tmux bind-key -r L resize-pane -R "$pane_resize"
40 | }
41 |
42 | pane_split_bindings() {
43 | tmux bind-key "|" split-window -h -c "#{pane_current_path}"
44 | tmux bind-key "\\" split-window -fh -c "#{pane_current_path}"
45 | tmux bind-key "-" split-window -v -c "#{pane_current_path}"
46 | tmux bind-key "_" split-window -fv -c "#{pane_current_path}"
47 | tmux bind-key "%" split-window -h -c "#{pane_current_path}"
48 | tmux bind-key '"' split-window -v -c "#{pane_current_path}"
49 | }
50 |
51 | improve_new_window_binding() {
52 | tmux bind-key "c" new-window -c "#{pane_current_path}"
53 | }
54 |
55 | main() {
56 | pane_navigation_bindings
57 | window_move_bindings
58 | pane_resizing_bindings
59 | pane_split_bindings
60 | improve_new_window_binding
61 | }
62 | main
63 |
--------------------------------------------------------------------------------
/screenshots/pane_navigation.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tmux-plugins/tmux-pain-control/32b760f6652f2305dfef0acd444afc311cf5c077/screenshots/pane_navigation.gif
--------------------------------------------------------------------------------
/screenshots/pane_resizing.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tmux-plugins/tmux-pain-control/32b760f6652f2305dfef0acd444afc311cf5c077/screenshots/pane_resizing.gif
--------------------------------------------------------------------------------
/screenshots/pane_resizing.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tmux-plugins/tmux-pain-control/32b760f6652f2305dfef0acd444afc311cf5c077/screenshots/pane_resizing.psd
--------------------------------------------------------------------------------
/screenshots/pane_splitting.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tmux-plugins/tmux-pain-control/32b760f6652f2305dfef0acd444afc311cf5c077/screenshots/pane_splitting.gif
--------------------------------------------------------------------------------
/screenshots/pane_splitting.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tmux-plugins/tmux-pain-control/32b760f6652f2305dfef0acd444afc311cf5c077/screenshots/pane_splitting.psd
--------------------------------------------------------------------------------