LoginSignup
3
0

More than 5 years have passed since last update.

tmux

Last updated at Posted at 2014-07-21

tmux basic concept

Screen Shot 2014-08-03 at 12.50.59 PM.png

command

general

attach existing session

tmux attach -t <settion name>

detach current session

prefix + d

reload configuration file again

prefix + :source-file ~/.tmux.conf

List all key bindings

prefix + ?

session

Detach the current session.

prefix + d

Select a new session for the attached client interactively.

prefix + s

Screen Shot 2014-08-03 at 1.03.10 PM.png

Kill last joined session.

tmux kill-session

window

Create a new window

prefix + c

Change to the previous window

prefix + p

Change to the next window

prefix + n

Choose window from a current session

prefix + w

Screen Shot 2014-07-25 at 0.29.48.png

pane

Split specific pane

  • "bash" is window name
  • "0" is pane name
  • split "0" pane on "bash" window horizontally
tmux split-window -t "bash.0" -h

Split the current pane horizontally.

prefix + "

Screen Shot 2014-08-03 at 5.21.02 PM.png

Split the current pane vertically.

prefix + %

Screen Shot 2014-08-03 at 5.22.31 PM.png

Select the next pane in the current window.

prefix + o

Break the current pane out of the window.

prefix + !

Move pane from the specifed window.

join-pane -s :<window name>

Move pane to the specifed window.

join-pane -t :<window name>

Show the time.

prefix + t

Screen Shot 2014-08-03 at 1.22.53 PM.png

tmux.conf sample

tmux.conf
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on

bind -n M-Space next-window
bind y send-keys 'set-window-option synchronize-panes' Enter

## unbind default prefix key
unbind-key C-b

## make Ctrl+j prefix key
set-option -g prefix C-j
bind-key C-j send-prefix

# synchronize shortcut key
bind e setw synchronize-panes on
bind E setw synchronize-panes off

tmux tips

share session with other operator

tmuxlogin.sh

Open multiple tmux panes, each logged into a different server
https://github.com/azat/scripts/blob/master/tmuxlogin.sh

tmuxlogin.sh -w session -t window server1 server2 server3 server4


Screen Shot 2014-08-03 at 5.03.06 PM.png

cmatrix

Screen Shot 2014-07-21 at 18.20.00.png

~/.tmux.conf
set -g lock-after-time 600
set -g lock-command "cmatrix -s -b"

tmux installation

source installation

# get source file
wget http://downloads.sourceforge.net/tmux/tmux-1.8.tar.gz
wget -k --no-check-certificate https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

# libevent installation
tar zxvf libevent-2.0.21-stable.tar.gz
./configure --prefix=/home/toripiyo 2>&1 | tee _configure.log
make 2>&1 | tee _make.log
make install 2>&1 | tee _make_install.log

# copy behavior settings
## Copy from tmux buffer to system buffer (clipboard)
http://www.rushiagr.com/blog/2016/06/16/everything-you-need-to-know-about-tmux-copy-pasting/
Go to iTerm2 > Preferences > “General” tab, and in the “Selection” section, check the box which says “Applications in terminal may access clipboard” if it isn’t checked.

# tmux installation
DIR="$HOME/lib"
./configure CFLAGS="-I$DIR/include" LDFLAGS="-L$DIR/lib" --prefix=/home/toripiyo/tmux-1.8 2>&1 | tee _configure.log
make 2>&1 | tee _make.log
make install 2>&1 | tee _make_install.log

copy behavior settings

Copy from tmux buffer to system buffer (clipboard)

http://www.rushiagr.com/blog/2016/06/16/everything-you-need-to-know-about-tmux-copy-pasting/
Go to iTerm2 > Preferences > “General” tab, and in the “Selection” section, check the box which says “Applications in terminal may access clipboard”

tmux trouble shooting

tmux cannot open atom from console

[17:38:13 - 15-02-01] /Users/toripiyo/program/rails/housmart/db % atom seeds.rb
LSOpenURLsWithRole() failed for the application /opt/homebrew-cask/Caskroom/atom/latest/Atom.app with error -10810.
  1. upgrade reattach-to-user-namespace.
[18:59:14 - 15-02-01] /Users/toripiyo % reattach-to-user-namespace -l
warning: unsupported new OS, trying as if it were 10.6-10.8
fatal: _vprocmgr_move_subset_to_user failed
[18:59:20 - 15-02-01] /Users/toripiyo % brew upgrade reattach-to-user-namespace
==> Upgrading 1 outdated package, with result:
reattach-to-user-namespace 2.3
==> Upgrading reattach-to-user-namespace
==> Downloading https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/archive/v2.3.tar.gz
######################################################################## 100.0%
==> Patching
==> make
?  /usr/local/Cellar/reattach-to-user-namespace/2.3: 6 files, 48K, built in 6 seconds
  1. add following configuration on .tmux.conf http://befool.co.jp/blog/jiska/upgrade-to-yosemite-after-that/
# Fix LSOpenURLsWithRole() error on OS X. Requires reattach-to-user-namespace
# # to be installed.
set-option -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL"

reference

tmux cheet sheet
https://gist.github.com/Geraint/7724164
1分で実現できるtmuxのTips x3 (ついでにinstall to Mac,CentOS,Debian/Ubuntu)
http://qiita.com/nntsugu@github/items/107cbd6cd6db2aa46172
Sharing remote terminal session between two users with Tmux
http://readystate4.com/2011/01/02/sharing-remote-terminal-session-between-two-users-with-tmux/

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0