Tmux Configuration ===================== Tmux configuration, that supercharges your [tmux](https://tmux.github.io/) to build cozy and cool terminal environment.  Table of contents ----------------- 1. [Features](#features) 1. [Installation](#installation) 1. [General settings](#general-settings) 1. [Key bindings](#key-bindings) 1. [Status line](#status-line) 1. [Nested tmux sessions](#nested-tmux-sessions) 1. [Themes and customization](#themes-and-customization) 1. [iTerm2 and tmux integration](#iterm2-and-tmux-integration) Features --------- - "C-a" prefix instead of "C-b" (screen like) - support for nested tmux sessions - configurable visual theme/colors, with some elements borrowed from [Powerline](https://github.com/powerline/powerline) - can apply different configuration whether your session is on local or remote machine - supercharged and cozy status line - status line: CPU, memory usage, system load average metrics - status line: username and hostname, current date time - status line: battery information in status line - status line: visual indicator when you press `prefix` - status line: visual indicator when pane is zoomed - status line: online/offline visual indicator - toggle visibility of status line - monitor windows for activity/silence - scroll and copy mode improvements - prompt to rename window right after it's created - highlight focused pane - merge current session with existing one (move all windows) - integration with 3rd party plugins: [tmux-sidebar](https://github.com/tmux-plugins/tmux-sidebar), [tmux-copycat](https://github.com/tmux-plugins/tmux-copycat), [tmux-open](https://github.com/tmux-plugins/tmux-open), [tmux-plugin-sysstat](https://github.com/samoshkin/tmux-plugin-sysstat) **TBD**: - [ ] retain current path when new pane is created - [ ] integration with clipboard - [ ] fix installation script to properly install TPM Installation ------------- The prerequisite is installed tmux >= "2.4" and [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) ``` $ git clone https://github.com/samoshkin/tmux-config.git $ ./tmux-config/install.sh ``` Installation script will copy files to `~/.tmux` directory, symlink main `~/.tmux` config file. If you already have existing `~/tmux.conf`, backup will be created. Note, that after you launch tmux, plugins needs to be installed. Hit `C-a Shift-i` keybinding to install all tmux plugins. - [ ] **TODO:** automate TPM and tmux plugin installation General settings ---------------- Windows and pane indexing starts from `1` rather than `0`. Scrollback history limit is set to `20000`. Automatic window renameing is turned off. Aggresive resizing is on. Message line display timeout is `1.5s`. Mouse support in `on`. 256 color palette support is turned on, make sure that your parent terminal is configured propertly. See [here](https://unix.stackexchange.com/questions/1045/getting-256-colors-to-work-in-tmux) and [there](https://github.com/tmux/tmux/wiki/FAQ) ``` # parent terminal $ echo $TERM xterm-256color # jump into a tmux session $ tmux new $ echo $TERM screen-256color ``` Key bindings ----------- So `~/.tmux.conf` overrides default key bindings for many action, to make them more reasonable, easy to recall and comforable to type. Let's go through them. If you are an iTerm2 user, third column describes the keybinding of similar "action" in iTerm2. It's possible to reuse very same keys you already get used to and tell iTerm2 to execute analogous tmux actions. See [iTerm2 and tmux integration](#iterm2-and-tmux-integration) section below.
| tmux key | Description | iTerm2 key |
C-a |
Default prefix, used instead of "C-b". Same prefix is used in screen program, and it's easy to type. The only drawback of "C-a" is that underlying shell does not receive the keystroke to move to the beginning of the line. | - |
<prefix> C-e |
Open ~/.tmux.conf file in your $EDITOR | - |
<prefix> C-r |
Reload tmux configuration from ~/.tmux.conf file | - |
<prefix> r |
Rename current window | - |
<prefix> R |
Rename current session | - |
<prefix> _ |
Split new pane horizontally | ⌘⇧D |
<prefix> | |
Split new pane vertically | ⌘D |
<prefix> < |
Select next pane | ⌘[ |
<prefix> > |
Select previous pane | ⌘] |
<prefix> ← |
Select pane on the left | ⌘⌥← |
<prefix> → |
Select pane on the right | ⌘⌥→ |
<prefix> ↑ |
Select pane on the top | ⌘⌥↑ |
<prefix> ↓ |
Select pane on the bottom | ⌘⌥↓ |
<prefix> C-← |
Resize pane to the left | ^⌘← |
<prefix> C-→ |
Resize pane to the right | ^⌘→ |
<prefix> C-↑ |
Resize pane to the top | ^⌘↑ |
<prefix> C-↓ |
Resize pane to the bottom | ^⌘↓ |
<prefix> > |
Move to next window | ⌘⇧] |
<prefix> < |
Move to previous window | ⌘⇧[ |
<prefix> Tab |
Switch to most recently used window | ^Tab |
<prefix> L |
Link window from another session by entering target session and window reference | - |
<prefix> \ |
Swap panes back and forth with 1st pane. When in main-horizontal or main-vertical layout, the main panel is always at index 1. This keybinding let you swap secondary pane with main one, and do the opposite. | ⌘\ |
<prefix> C-o |
Swap current active pane with next one | - |
<prefix> + |
Toggle zoom for current pane | ⌘⇧Enter |
<prefix> x |
Kill current pane | ⌘W |
<prefix> X |
Kill current window | ⌘⌥W |
<prefix> C-x |
Kill other windows but current one (with confirmation) | - |
<prefix> Q |
Kill current session (with confirmation) | - |
<prefix> C-u |
Merge current session with another. Essentially, this moves all windows from current session to another one | - |
<prefix> d |
Detach from session | - |
<prefix> D |
Detach other clients except current one from session | - |
<prefix> C-s |
Toggle status bar visibility | - |
<prefix> m |
Monitor current window for activity | - |
<prefix> M |
Monitor current window for silence by entering silence period | - |
<prefix> F12 |
Switch off all key binding and prefix hanling in current window. See "Nested sessions" paragraph for more info | - |