Installation
Usally brew install tmux
should work but not for me.
Installing libevent
Read this blog for more details
I tried to install tmux but I had error messages for iibevent which I installed through homebrew. So I first downloaded libevent.
$ cd Downloads\libevent-2.0.21-stable
$ ./configure && make
$ sudo make install
Installing tmux
Then I downloaded tmux.
$ cd ..
$ cd tmux-1.8
$ ./configure && make
$ sudo make install
How to use it
# start tmux
$ tmux
# or give the session a name, with -s <session_name>
$ tmux new -s rubyvim
Controlling Panes
# Split into two panes.
Ctrl-b %
# Split the pane horizontally
Ctrl-b "
# Switch to the next pane
Ctrl-b o
# To cycle through the panes, use up, down, left or right key
Ctrl-b Up
# Cycle through layouts
Ctrl-b space
# Kill a pane
exit
# or
Ctrl-b x
Windows
# To create a new window:
Ctrl-b c
# To move to the next window in the index:
Ctrl-b n
# To move backwards in the index:
Ctrl-b p
# To move to nth window, n = 1, 2, 3 etc
Ctrl-b n
# name widnow
Ctrl-b ,
# Find a window
Ctrl-b f
# and type a name
# Kill window
Ctrl-b &
# split windows with commands
$ tmux split-window
Session
# To go back to the normal terminal screen, you need to detach it from a session.
Ctrl-b d
# To go back to the session you need to re-attach to a session
tmux attach -t [session name]
# View active sessions:
tmux list-sessions
# or shorthand
$ tmux ls
# A list of all command keys is accessible with:
Ctrl-b ?
# kill a session
$ tmux ls
0: 1 windows (created Sat Aug 17 00:03:56 2013) [80x23]
2: 1 windows (created Sat Aug 24 16:47:58 2013) [120x34]
$ tmux kill-session -t 2
$ tmux ls
0: 1 windows (created Sat Aug 17 00:03:56 2013) [80x23]
Command mode
# enter command mode
Ctrl-b :
# then create a new window
new-window -n console
# create a new window with starting a top program
new-window -n processes "top"
# quit the program
q
tmux.sh
tmux.sh
# !/bin/sh
tmux new-session -d -s sample_app
tmux new-window -t sample_app:2 -n 'server' 'bundle exec rails server'
tmux new-window -t sample_app:3 -n 'vim' 'vi'
tmux attach -t sample_app
Resources
[tmux shortcuts & cheatsheet]
(https://gist.github.com/MohamedAlaa/2961058)