Skip to content

Tmux configuration, that supercharges your tmux to build cozy and cool terminal environment

Notifications You must be signed in to change notification settings

FelixRTU/tmux-config

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tmux Configuration

Tmux configuration, that supercharges your tmux and builds cozy and cool terminal environment.

intro

Table of contents

  1. Features
  2. Installation
  3. General settings
  4. Key bindings
  5. Status line
  6. Nested tmux sessions
  7. Copy mode
  8. Clipboard integration
  9. Themes and customization
  10. iTerm2 and tmux integration

Features

  • "C-a" prefix instead of "C-b" (screen like)
  • support for nested tmux sessions
  • local vs remote specific session configuration
  • scroll and copy mode improvements
  • supercharged status line
  • prompt to rename window/session right after it's created
  • newly created windows and panes retain current working directory
  • monitor windows for activity/silence
  • highlight focused pane
  • merge current session with existing one (move all windows)
  • configurable visual theme/colors, with some elements borrowed from Powerline

Status line widgets:

  • username and hostname, current date time
  • visual indicator when you press prefix
  • visual indicator when you're in Copy mode
  • visual indicator when pane is zoomed
  • toggle visibility of status line

Installation

Prerequisites:

  • tmux >= "v2.4"

To install tmux-config:

$ git clone https://github.com/samoshkin/tmux-config.git
$ ./tmux-config/install.sh

install.sh script does following:

  • copies files to ~/.tmux directory
  • symlink tmux config file at ~/.tmux.conf, existing ~/.tmux.conf will be backed up
  • Tmux Plugin Manager will be installed at default location ~/.tmux/plugins/tpm, unless already presemt
  • required tmux plugins will be installed

Finally, you can jump into a new tmux session:

$ tmux new

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.

256 color palette support is turned on, make sure that your parent terminal is configured propertly. See here and there

# 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.

tmux key Description
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
<prefix> % Split new pane vertically
<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> n Move to next window
<prefix> N Move to previous window
<prefix> Tab Switch to most recently used window
<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> z Toggle zoom for current pane
<prefix> x Kill current pane
<prefix> X Kill current window
<prefix> C-x Kill other windows but current one (with confirmation)
<prefix> Q Kill current session (with confirmation)
<prefix> C-u Move current window to another session by given name
<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
<prefix> S Create new session and ask for name
<prefix> s List all sessions
<prefix> c Create new window and ask for name
<prefix> + Sync Panes
<prefix> y Sync Panes
<prefix> [ Copy Mode
<prefix> w copy
<prefix> ] paste
<prefix> p paste
<prefix> C-p show all buffers (paste with p, delete with d)
<prefix> y (requires xsel) yank commandline / selection (copy mode) to clipboard -
<prefix> Y copy current pane current working directory to the clipboard / copy+paste selction to commandline (copy mode) -

Status line

I've started with Powerline as a status line, but then realized it's too fat for my Macbook 15'' display, it hardly can fit all those fancy arrows, widgets and separators, so that I can only see one window "tab".

So I decide to make my feet wet, with the idea to keep it dense, and include essential widgets. Sometimes it tries to replicate OSX topbar (battery, date time).

Left part: status line left

Right part: status line right

The left part contains only current session name.

Window tabs use Powerline arrows glyphs, so you need to install Powerline enabled font to make this work. See Powerline docs for instructions and here is the collection of patched fonts for powerline users

The right part of status line consists of following components:

  • username and hostname (invaluable when you SSH onto remote host)
  • current date time
  • visual indicator when you press prefix key: [^A].
  • visual indicator when pane is zoomed: [Z]

You might want to hide status bar using <prefix> C-s keybinding.

Nested tmux sessions

When in outer session, simply press F12 to toggle off all keybindings handling in outer session. Now work with inner session using the same keybinding scheme and same keyprefix. Press F12 to turn on outer session back.

nested sessions

You might notice that when key bindings are "OFF", special [OFF] visual indicator is shown in the status line, and status line changes its style (colored to gray).

Local and remote sessions

Remote session is detected by existence of $SSH_CLIENT variable. When session is remote, following changes are applied:

  • status line is docked to bottom; so it does not stack with status line of local session

You can apply remote-specific settings by extending ~/.tmux/.tmux.remote.conf file.

Themes and customization

All colors related to theme are declared as variables. You can change them in ~/.tmux.conf.

# This is a theme CONTRACT, you are required to define variables below
# Change values, but not remove/rename variables itself
color_dark="$color_black"
color_light="$color_white"
color_session_text="$color_blue"
color_status_text="colour245"
color_main="$color_orange"
color_secondary="$color_purple"
color_level_ok="$color_green"
color_level_warn="$color_yellow"
color_level_stress="$color_red"
color_window_off_indicator="colour088"
color_window_off_status_bg="colour238"
color_window_off_status_current_bg="colour254"

Note, that variables are not extracted to dedicated file, as it should be, because for some reasons, tmux does not see variable values after sourcing theme.conf file. Don't know why.

About

Tmux configuration, that supercharges your tmux to build cozy and cool terminal environment

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%