Thursday, September 10, 2020

tmux multiplexer

 Used for enhancing your work area in linux command line.

Useful Links:


yum install tmux

Tmux has sessions, windows and panes hierarchy.

tmux -V #Version
    new #new session
    new -s [name of session]
    ls #list sessions
    attach-session -t 3
    a # #attach last session with #
    a -t [name of session] #reattaches to the session.
    rename-session -t 0 database
    kill-server

    
    
Ctrl + b

  •     ? - help
Sessions
  •     d - detach ; D - which session to detach; 
  •     s sessions; ) , (  , switch sessions;  
  •     new #new session
  •     new -s [name of session]
  •     ls #list sessions
  •     attach-session -t 3
  •     a # #attach last session with #
  •     a -t [name of session] #reattaches to the session.
  •     rename-session -t 0 database
  •     kill-server

Windows
    •     c - create window;  
    •     switch windows; by n,p  <number>;     n(next), p(previous), number
    •     , - rename window
Panes
    •     " - split horizontally; display split into 2 different panes.
    •     % - vertical split
    •     [arrow key] to move between panes
    •     [HOLD arrow key] to resize  panes
    •     x kill current pane
    •     exit or ctrl_d exit a pane
    •    z - full screen pane and back;
    •     :resize-pane -D 2 #-U for up, -D for down -L for left and -R for right. The last part is the number of lines to move it over by.

  •     x - kill
  •     :list-keys

    
    ~/.tmux.conf
    
Copy paste; hold Shift key then select from mouse

If you press shift while doing things with the mouse, that overrides the mouse protocol and lets you select/paste. It's documented in the xterm manual for instance, and most terminal emulators copy that behavior.


https://gist.github.com/spicycode/1229612

oracle@localhost $ cat .tmux.conf
# Uncomment the lines with the options you want to activate (by deleting the preceding "#")

# Allow mouse interaction
#setw -g mode-mouse on
set -g mode-mouse on

# Allow mouse to select which pane to use
set -g mouse-select-pane on

# Allow mouse dragging to resize panes
set -g mouse-resize-pane on

# Reload tmux config
bind r source-file ~/.tmux.conf

#set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=white]%H:%M#[default]'

On unix you can also use alternatives like screen or  gcm.