Adjustments to Style & Content

Style changes
  - Site format has changed back to ~80 columns, certain rows have had line
    breaks removed.
  - Indentation has been adjusted globally to give additional space and
    consistency.
  - Configuring Tmux has been separated due to long lines causing the entire
    page to scroll horizontally and block text.
  - tmux.conf has been reorganized to better explain settings categorically to
    new users.

 Content Changes
  - Unmapping the prefix key contained erroneous data
  - Misc section and it's contained "bind r source.." setting are superfluous,
    as when this points to the next file to use in the configuration, not the
    current file. Since no additional configuration files have been used, it
    has been removed.
This commit is contained in:
jmaud 2014-10-07 16:55:40 -04:00
parent ce3fb267f7
commit fd29de7f59

View File

@ -2,22 +2,23 @@
category: tool category: tool
tool: tmux tool: tmux
contributors: contributors:
- ["kaernyk", "http://github.com/kaernyk"] - ["kaernyk", "https://github.com/kaernyk"]
- ["jmaud". "https://github.com/jmaud"]
filename: LearnTmux.txt filename: LearnTmux.txt
--- ---
<a href="http://tmux.sourceforge.net/"> <a href="http://tmux.sourceforge.net/">
tmux</a> is a terminal multiplexer: it enables a number of terminals tmux</a> is a terminal multiplexer: it enables a number of terminals
to be created, accessed, and controlled from a single screen. tmux to be created, accessed, and controlled from a single screen. tmux
may be detached from a screen and continue running in the background may be detached from a screen and continue running in the background
then later reattached. then later reattached.
``` ```
tmux [command] # Run a command tmux [command] # Run a command
# 'tmux' with no commands will create a new # 'tmux' with no commands will create a new session
session
new # Create a new session new # Create a new session
-s "Session" # Create named session -s "Session" # Create named session
@ -54,7 +55,7 @@ then later reattached.
## Key Bindings ## Key Bindings
# The method of controlling an attached tmux session is via key # The method of controlling an attached tmux session is via key
# combinations called 'Prefix' keys. # combinations called 'Prefix' keys.
---------------------------------------------------------------------- ----------------------------------------------------------------------
@ -63,47 +64,48 @@ then later reattached.
(M-1) = Meta + 1 -or- Alt + 1 (M-1) = Meta + 1 -or- Alt + 1
---------------------------------------------------------------------- ----------------------------------------------------------------------
? # List all key bindings ? # List all key bindings
: # Enter the tmux command prompt : # Enter the tmux command prompt
r # Force redraw of the attached client r # Force redraw of the attached client
c # Create a new window c # Create a new window
! # Break the current pane out of the window. ! # Break the current pane out of the window.
% # Split the current pane into two, left and right % # Split the current pane into two, left and right
" # Split the current pane into two, top and bottom " # Split the current pane into two, top and bottom
n # Change to the next window n # Change to the next window
p # Change to the previous window p # Change to the previous window
{ # Swap the current pane with the previous pane { # Swap the current pane with the previous pane
} # Swap the current pane with the next pane } # Swap the current pane with the next pane
s # Select a new session for the attached client s # Select a new session for the attached client
interactively interactively
w # Choose the current window interactively w # Choose the current window interactively
0 to 9 # Select windows 0 to 9 0 to 9 # Select windows 0 to 9
d # Detach the current client d # Detach the current client
D # Choose a client to detach D # Choose a client to detach
& # Kill the current window & # Kill the current window
x # Kill the current pane x # Kill the current pane
Up, Down # Change to the pane above, below, left, or right Up, Down # Change to the pane above, below, left, or right
Left, Right Left, Right
M-1 to M-5 # Arrange panes: M-1 to M-5 # Arrange panes:
# 1) even-horizontal # 1) even-horizontal
# 2) even-vertical # 2) even-vertical
# 3) main-horizontal # 3) main-horizontal
# 4) main-vertical # 4) main-vertical
# 5) tiled # 5) tiled
C-Up, C-Down # Resize the current pane in steps of one cell C-Up, C-Down # Resize the current pane in steps of one cell
C-Left, C-Right C-Left, C-Right
M-Up, M-Down # Resize the current pane in steps of five cells M-Up, M-Down # Resize the current pane in steps of five cells
M-Left, M-Right M-Left, M-Right
```
### Configuring ~/.tmux.conf ### Configuring ~/.tmux.conf
@ -111,15 +113,36 @@ then later reattached.
tmux.conf can be used to set options automatically on start up, much tmux.conf can be used to set options automatically on start up, much
like how .vimrc or init.el are used. like how .vimrc or init.el are used.
```
# Example tmux.conf # Example tmux.conf
# 2014.9 # 2014.10
### General
###########################################################################
# Enable UTF-8
setw -g utf8 on
set-option -g status-utf8 on
# Scrollback/History limit
set -g history-limit 2048
# Index Start
set -g base-index 1
# Mouse
set-option -g mouse-select-pane on
### Keybinds ### Keybinds
###################################################################### ###########################################################################
# Unbind C-b as the default prefix # Unbind C-b as the default prefix
unbind-key C-befix C-a unbind-key C-b
# Set new default prefix
set-option -g prefix `
# Return to previous window when prefix is pressed twice # Return to previous window when prefix is pressed twice
bind-key C-a last-window bind-key C-a last-window
@ -129,12 +152,15 @@ bind-key ` last-window
bind-key F11 set-option -g prefix C-a bind-key F11 set-option -g prefix C-a
bind-key F12 set-option -g prefix ` bind-key F12 set-option -g prefix `
# Activate inner-most session (when nesting tmux) # Keybind preference
# to send commands setw -g mode-keys vi
bind-key a send-prefix set-option -g status-keys vi
# Index Start # Moving between panes with vim movement keys
set -g base-index 1 bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Window Cycle/Swap # Window Cycle/Swap
bind e previous-window bind e previous-window
@ -142,23 +168,21 @@ bind f next-window
bind E swap-window -t -1 bind E swap-window -t -1
bind F swap-window -t +1 bind F swap-window -t +1
# easy-to-remember split pane commands # Easy split pane commands
bind | split-window -h bind = split-window -h
bind - split-window -v bind - split-window -v
unbind '"' unbind '"'
unbind % unbind %
# moving between panes with vim movement keys # Activate inner-most session (when nesting tmux) to send commands
bind h select-pane -L bind-key a send-prefix
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
### Theme ### Theme
##################################################################### ###########################################################################
# Statusbar Color Palette # Statusbar Color Palatte
set-option -g status-justify left set-option -g status-justify left
set-option -g status-bg black set-option -g status-bg black
set-option -g status-fg white set-option -g status-fg white
@ -187,14 +211,7 @@ setw -g window-status-activity-fg yellow
### UI ### UI
###################################################################### ###########################################################################
# Statusbar
set-option -g status-utf8 on
# Keybind preference
setw -g mode-keys vi
set-option -g status-keys vi
# Notification # Notification
setw -g monitor-activity on setw -g monitor-activity on
@ -202,43 +219,14 @@ set -g visual-activity on
set-option -g bell-action any set-option -g bell-action any
set-option -g visual-bell off set-option -g visual-bell off
# Mouse
setw -g mode-mouse on
set-option -g mouse-select-pane on
set -g mouse-resize-pane on
set -g mouse-select-window on
# Automatically set window titles # Automatically set window titles
set-option -g set-titles on set-option -g set-titles on
set-option -g set-titles-string '#H:#S.#I.#P #W #T' # window number,program name,active (or not)
# window number,program name,active (or not)
set-option -g set-titles-string '#H:#S.#I.#P #W #T'
# Statusbar Adjustments # Statusbar Adjustments
set -g status-left '#[fg=red]#H#[fg=green]:#[fg=white]#S #[fg=green]][#[default]' set -g status-left "#[fg=red] #H#[fg=green]:#[fg=white]#S #[fg=green]][#[default]"
set -g status-interval 3
# Statusbar with right-aligned Date / Time
#set -g status-right '#[fg=green]][#[fg=white] #T #[fg=green]][ #[fg=blue]%Y-%m-%d #[fg=white]%H:%M#[default]'
# Show performance counters in statusbar # Show performance counters in statusbar
# Requires https://github.com/thewtex/tmux-mem-cpu-load/ # Requires https://github.com/thewtex/tmux-mem-cpu-load/
#set -g status-right '#[fg=green]][#[fg=white] #(tmux-mem-cpu-load 5 4) #[fg=green]][ #[fg=yellow]%H:%M#[default]' #set -g status-interval 4
#set -g status-right "#[fg=green]][ #[fg=white]#(tmux-mem-cpu-load) #[fg=green]][ #[fg=yellow]%H:%M #[default]"
### Misc
######################################################################
# Scrollback/History limit
set -g history-limit 4096
bind r source-file ~/.tmux.conf
```
### External Resources
<a href="http://tmux.sourceforge.net/">Tmux | Home</a><br>
<a href="http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/tmux.1?query=tmux">Tmux Manual page</a><br>
<a href="http://wiki.gentoo.org/wiki/Tmux">Archlinux Wiki</a><br>
<a href="https://wiki.archlinux.org/index.php/Tmux">Gentoo Wiki</a><br>
<a href="https://stackoverflow.com/questions/11558907/is-there-a-better-way-to-display-cpu-usage-in-tmux">Display CPU/MEM % in statusbar</a><br>