tmux

Back to REF main.




Most of these examples will use example session name "renard". But using a tmux session number should work also.

From outside tmux.

Start a new session:
  tmux

Start a new session called renard.
  tmux new -s renard

List sessions.
  tmux ls

Attach to a session named renard.
  tmux attach -t renard

Kill the session called renard.
  tmux kill-session -t renard

From inside or outisde a tmux session.

From inside tmux, to get to tmux command line:
  [prefix]:

At tmux command line.

Using
  [prefix]x    from inside tmux
  :xxx         from inside tmux, after [prefix]:
  tmux xxx     from outside tmux

---------------------------------

Start a new tmux session.
  :new

Start a new tmux session called renard.
  :new -s renard

Detach from a session.
  :detach
  tmux detach
  [prefix]d

Rename a session to give it the name renard.
  :rename-session renard

Kill session named renard.
  :kill-session -t renard

Kill the current session.
  :kill-session

Go to session list and kill session renard.
  - First move to a session other than renard, otherwise 
    you will exit tmux when renard is killed.
  [prefix]s
  :kill-session -t renard


Shortcuts to use from inside a tmux session.

[prefix]s    Go to a list of sessions from which we can switch to a new session.
[prefix]%    Split window into vertical panes.
[prefix]"    Split window into horizontal panes.
[prefix],    name a window


[prefix][
[prefix][page-up]
[prefix][page-down]
     - Enter terminal scroll mode and scroll up
       or down.
     - Use navigation keys.
     - q to exit.



/home/pat/.tmux.conf

# set -g default-terminal "screen-256color"

unbind C-b
set-option -g prefix C-j

## The following makes it that we can send C-j to the application 
## running inside tmux by doing C-[jj].
bind-key C-j send-prefix

## Use tmux vi-like keys for tmux copy mode.
setw -g mode-keys vi

## Use vim keys to move amuong panes.
bind h select-pane -L
bind l select-pane -R
bind k select-pane -U
bind j select-pane -D

bind H resize-pane -L 5
bind J resize-pane -D 5
bind K resize-pane -U 5
bind L resize-pane -R 5

## Newly created windows and panes open in current directory.
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"

############################################
## May be useful in future.

## use UTF-8
# set -g utf8
# set-window-option -g utf8 on

## shorten command delay
# set -sg escape-time 1
############################################