My personal guidelines, and only added shortcuts tested by myself.
# install deps
sudo yum install -y gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -LOk https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stable.tar.gz
tar -xf libevent-2.1.11-stable.tar.gz
cd libevent-2.1.11-stable
./configure --prefix=/usr/local
make
sudo make install
cd ..
# DOWNLOAD SOURCES FOR TMUX AND MAKE AND INSTALL
curl -LOk https://github.com/tmux/tmux/releases/download/3.1b/tmux-3.1b.tar.gz
tar -xf tmux-3.1b.tar.gz
cd tmux-3.1b
LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" ./configure --prefix=/usr/local
make
sudo make install
mv /home/ec2-user/tmux-3.1b/tmux /bin/tmux
# pkill tmux
# close your terminal window (flushes cached tmux executable)
# open new shell and check tmux version
tmux -V
Start new:
tmux
Start new with session name:
tmux new -s myname
List sessions:
tmux ls
Attach:
tmux attach-session
Attach with id or named:
tmux a -t [#|myname]
kill session:
tmux kill-session -t myname
By default, command key bindings are prefixed by Ctrl-b
. For example, to vertically split a window type Ctrl-b+%
.
Another way for Ctrl
notation is to replace with this symbol ^
(up arrowhead) or C
. For example, ⌃-b+%
or C-b+%
.
A user-specific configuration file should be located at ~/.tmux.conf
.
This is the content for .tmux.conf
config file:
# General
set-option -g default-terminal screen-256color
# Increase the display time of the pane numbers seen
set-option -g display-panes-time 2000
# Increase scrollback buffer size
set-option -g history-limit 10000
# Set inactive/active window styles
set-option -g window-style fg=colour240,bg=colour236
set-option -g window-active-style fg=colour250,bg=black
# Set the pane border colors
set-option -g pane-border-style bg=colour235,fg=colour238
set-option -g pane-active-border bg=colour235,fg=colour238
# Show reloaded message in bright white
set-window-option -g pane-active-border-style bg=colour235,fg=colour238
set-window-option -g pane-border-style bg=colour235,fg=colour238
set-window-option -g xterm-keys on
# Time and date on right-hand side
set-option -g status-right "#[fg=colour245]%d %b #[fg=colour256] %R"
set-option -g status-interval 60
# Status bar
set-option -g status-bg colour235
set-option -g status-fg colour208
# Windows list
#setw -g mode-bg colour235
#setw -g mode-fg colour208
# Configure Status Info
set-option -g status-right '#(cd #{pane_current_path}; git rev-parse --abbrev-ref HEAD) | #H | %d/%m/%Y %H:%M '
set-option -g status-right-length 50
This can be done either from within tmux, by pressing Ctrl+B
and then :
to bring up a command prompt, and typing:
source-file ~/.tmux.conf
By default prefix binding of Ctrl-b
can be changed to Ctrl-a
by adding the following commands in your configuration file:
unbind C-b
set -g prefix C-a
bind C-a send-prefix
For enable mouse support.
set -g mouse on
Ctrl-b+d detach
Ctrl-b+t big clock
Ctrl-b+? list shortcuts
Ctrl-b+: prompt
Ctrl-b+c create window
Ctrl-b+w list windows
Ctrl-b+n next window
Ctrl-b+p previous window
Ctrl-b+f find window
Ctrl-b+, name window
Ctrl-b+& kill window
Panes is the split into windows.
Ctrl-b+% vertical split
Ctrl-b+" horizontal split
Ctrl-b+q show pane numbers and press key number to go to pane.
Ctrl-b+x kill pane
Ctrl-b+o swap panes
Ctrl-b+left go to the next pane on the left
Ctrl-b+right (or one of these other directions)
Ctrl-b+up (or one of these other directions)
Ctrl-b+down (or one of these other directions)
Ctrl-b+; go to the ‘last’ (previously used)
Ctrl-b+Alt-Up resize to Up
Ctrl-b+Alt-Down resize to Down
Ctrl-b+Alt-Left resize to Left
Ctrl-b+Alt-Right resize to Right
Ctrl-b+z Maximize / Minimize
Ctrl-b+[ Enter into Copy/Scroll mode, press q or Esc to quit.
- Use the arrow key to move by line by line.
- Press Ctrl-SPACE to start copying.
- Press ALT-w or Ctrl-w to copy into Tmux buffer. Or press Enter on Mac OS's.
- Press Ctrl-b+] to paste in a possibly different Tmux pane/window.
- To move line by line with stop cursor use the combination Ctrl-[Up|Down] or Shift-[k|j].
- In MAC to move page by page use Fn-[Up|Down].
Where you are into Copy/Scroll mode Ctrl-b+[
, press Ctrl-s
then type the string to search for and press Enter
. Press n
to search for the same string again. Press Shift-n
for reverse search. Press q
to exit.
You have tmux on local environment, and connet via SSH to bastion server and them start tmux session there. This is called nested sessions.
Laptop (tmux) ---ssh---> Bastion (tmux)
The most common solution is to press prefix twice (prefix is a keybinding that puts tmux in a command mode, usually it's Ctrl-b
, but some people prefer remapping it to screen-like Ctrl-a
).
The commands that you type in your terminal are first handled by your local tmux instance, then handled by the nested tmux session. This means you need to escape twice to go to the nested instance:
For example, to deatach from tmux on server, press Ctrl-b-b+d
.
Dependencies? Yes, On recent version of Mac OS's greater than 10.5 implement peculiarities security, as process and daemons haven’t access to user-level services like the pasteboard since OS. There’s a library called reattach-to-user-namespace
that uses some private operating system functions to get tmux access to the pasteboard.
brew install reattach-to-user-namespace