tmux 1.8 Released
tmux.sourceforge.net
tmux.sourceforge.net
"tmux is a terminal multiplexer"
"What is a terminal multiplexer? It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more. See the manual."
That's awesome. So many times someone posts on HN "CaffBook.ly.errr 0.98 now released" and I have no idea what it is or why I would want it.
Some of it is arguable, but for me one of the greatest benefits is how tmux will auto-resize to the smallest terminal connected, making it useful for screen sharing or when connecting to an existing session from a mobile device.
If I get a chance, I'll give a go at converting the scripts for some of the layouts I use all the time, and see if it sticks.
Spoken like someone who's never actually looked into how complex YAML can be.
Well, I suppose it's possible, but it seems extremely unlikely.
I made it shortly after switching to tmux last year. I hope this kind of functionality will eventually be built-in to tmux.
I use vim-slime[1] to send strings to other panes in tmux. I never type anything directly into a REPL. I just send my code from Vim to it. It's amazing with lisp or python. (A little less amazing with php, as the php repl IS AWEFUL)
First impressions count.
If you want to configure tmux to use just a backtick as the escape, create ~/.tmux.conf
unbind C-b
set -g prefix `
bind-key ` send-prefix
When you need to type a backtick just press it twice.For screen, I used to do this:
escape ``
.. in ~/.screenrc, but I've just tried it and it seems that there's now no easy way to type a backtick when you need one.Query: in screen I can switch between two buffers by doing ctrl+a, ctrl+a. This doesn't work in tmux. How do I configure this to work in tmux?
"Ctrl-b n" for next-window?
Here's a scenario to show what I mean: you're in buffer 5. You switch to buffer 2. Now if you do ctrl+a, ctrl+a, you leap back to buffer 5. And if you do it again, you go back to buffer 2. This is great when you're editing code in one session and running it in the other.
bind C-a last-pane
but last-window exists too.
I've now switched last-window to bind C-s last-window, because it's fast to tap out.
bind C-a last-window
Switch the C-a for whatever your bind-key is. # use hjkl for moving
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R bind-key C-j resize-pane -D 8
bind-key C-k resize-pane -U 8
bind-key C-h resize-pane -L 8
bind-key C-l resize-pane -R 8a
I've never been able to get it to deal well with vast amounts of output well. Constant overwriting issues etc. Definitely prefer to use tmux + emacs considering the huge amount of stuff i end up throwing at my term.
M-x ansi-term
; Rename the buffer (escaping shell mode first)
C-c C-j M-x rename-buffer
; Shell responds to keyboard again
C-c C-k
; Split window in half horizontally
C-x 2
-----
I stole this (possibly from Steve Yegge or another source) long ago to somewhat automate the process of renaming terminal buffers:
(global-set-key (kbd "<f2>") 'visit-ansi-term)
;; Terminal awesomeness
(require 'term)
(defun visit-ansi-term ()
"If the current buffer is:
1) a running ansi-term named *ansi-term*, rename it.
2) a stopped ansi-term, kill it and create a new one.
3) a non ansi-term, go to an already running ansi-term
or start a new one while killing a defunt one"
(interactive)
(let ((is-term (string= "term-mode" major-mode))
(is-running (term-check-proc (buffer-name)))
(term-cmd "/usr/local/bin/zsh")
(anon-term (get-buffer "*ansi-term*")))
(if is-term
(if is-running
(if (string= "*ansi-term*" (buffer-name))
(call-interactively 'rename-buffer)
(if anon-term
(switch-to-buffer "*ansi-term*")
(ansi-term term-cmd)))
(kill-buffer (buffer-name))
(ansi-term term-cmd))
(if anon-term
(if (term-check-proc "*ansi-term*")
(switch-to-buffer "*ansi-term*")
(kill-buffer "*ansi-term*")
(ansi-term term-cmd))
(ansi-term term-cmd))))) (defun visit-ansi-term ()
"If the current buffer is:
1) a running ansi-term named *ansi-term*, rename it.
2) a stopped ansi-term, kill it and create a new one.
3) a non ansi-term, go to an already running ansi-term
or start a new one while killing a defunct one."
(interactive)
(let ((is-term (string= "term-mode" major-mode))
(is-ansi-term (string= "*ansi-term*" (buffer-name)))
(is-running (term-check-proc (buffer-name)))
(anon-term (get-buffer "*ansi-term*")))
(cond
((and is-term is-running is-ansi-term)
(call-interactively 'rename-buffer))
((and anon-term (if is-term
(and is-running (not is-ansi-term))
(term-check-proc "*ansi-term*")))
(switch-to-buffer "*ansi-term*"))
(t
(cond ((and is-term (not is-running))
(kill-buffer (buffer-name)))
((and anon-term (not (term-check-proc "*ansi-term*")))
(kill-buffer "*ansi-term*")))
(ansi-term "/usr/local/bin/zsh")))))cd /user@host:/home/user/
C-h f server-start
Shell users who use emacs mode (most ppl) may be annoyed by ctrl+a missing.
au BufRead,BufNewFile Makefile set noexpandtab bind-key C-a last-window bindkey 'a' last-window
bindkey C-a last-window
if you use the command frequently enough, it might be worthwhile binding `^a a` and `^a^a`, similar to the tactic of binding F1 to <esc> in vim escape ^@^@
On most keyboards, you can enter it with control-space, which is very easy to type and rarely used for other purposes (though emacs uses for `set-mark-command`).Control-] can also be a good choice (at least for US-style keyboards that don't require shift for the square brackets).
* Resizing panes will now reflow the text inside them.
Finally! I did not expect this feature, I thought the author was opposed to it. It is the one thing I have missed from screen (and part of the reason why I originally started using screen, since xterm does not reflow on resize either).Alternatively, I never figured out how to select / copy text just as fast in tmux / vim / etc as with the mouse.
This appears to be a helpful article: http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/
setw -g mode-mouse on
setw -g mouse-select-window on
setw -g mouse-select-pane on
setw -g mouse-resize-pane on
Then you can scroll in panes, but also select like normal by holding alt/option.But tmux 1.8 mouse wheel scrolling seems much improved over tmux 1.6 - to the point that it looks quite usable.
> * Control mode, which is a way for a client to send tmux commands. > Currently more useful to users of iterm2.
With this, if you connect to tmux via iTerm2, you can get it to pop up a window with tabs for each shell in the tmux session. History via the mouse wheel is native, changing tabs is native, new tab is native. Essentially you don't need to know any of the tmux commands at all unless you connect from a terminal program that doesn't know the protocol.
* layout redo/undo has been removed.
Normal Changes ==============
* Add halfpage up/down bindings to copy mode.
* Session choosing fixed to work with unattached sessions.
* New window options window-status-last-{attr,bg,fg} to denote the last window which was active.
* Scrolling in copy-mode now scrolls the region without moving the mouse cursor.
* run-shell learnt '-t' to specify the pane to use when displaying output.
* Support for middle-click pasting.
* choose-tree learns '-u' to start uncollapsed.
* select-window learnt '-T' to toggle to the last window if it's already current.
* New session option 'assume-paste-time' for pasting text versus key-binding actions.
* choose-* commands now work outside of an attached client.
* Aliases are now shown for list-commands command.
* Status learns about formats.
* Free-form options can be set with set-option if prepended with an '@' sign.
* capture-pane learnt '-p' to send to stdout, and '-e' for capturing escape sequences, and '-a' to capture the alternate screen, and '-P' to dump pending output.
* Many new formats added (client_session, client_last_session, etc.)
* Control mode, which is a way for a client to send tmux commands. Currently more useful to users of iterm2.
* resize-pane learnt '-x' and '-y' for absolute pane sizing.
* Config file loading now reports errors from all files which are loaded via the 'source-file' command.
* 'copy-pipe' mode command to copy selection and pipe the selection to a command.
* Panes can now emit focus notifications for certain applications which use those.
* run-shell and if-shell now accept formats.
* resize-pane learnt '-Z' for zooming a pane temporarily.
* new-session learnt '-A' to make it behave like attach-session.
* set-option learnt '-o' to prevent setting an option which is already set.
* capture-pane and show-options learns '-q' to silence errors.
* New command 'wait-for' which blocks a client until woken up again.
* Resizing panes will now reflow the text inside them.
* Lots and lots of bug fixes, fixing memory-leaks, etc.
* Various manpage improvements.
This is all I needed to know to upgrade.
If you're on a mac and use iTerm2, using tmux is somewhat of a no-brainer, thanks to the integration between tmux and iTerm2[2].
1: http://sourceforge.net/p/tmux/tmux-code/ci/master/tree/FAQ 2: https://code.google.com/p/iterm2/wiki/TmuxIntegration
tmux seemed slower while switching windows, plus I like the simplicity of screen.
Definitely recommend the switch. You might be dreading it, but two days into tmux you won't regret it. It took many weeks trying to convince myself screen is better until I actually tried tmux out.
unbind C-b
set -g prefix C-aThe only two pains that come with it are a) having to type `` to get a single `, and b) pasting anything containing a backtick behaves as if you'd typed it out.
I attempted to start using it a couple of weekends ago but wasn't able to find any good documentation with my google-fu.
http://pragprog.com/book/bhtmux/tmux
Really good introduction, and the included config file is a good start.
Either way, thanks for reading. I hope it's enjoyable. Some minor updates are coming to the book too.
Inception!
but assuming you mean 'panes', it seems you can:
Ctrl-b o
to move around the current window's panes clockwise. Although I prefer inputing a given direction like the other replier suggested with arrow keys.
For me moving between windows and panes is something that I do a lot. So much so that I removed the need to use the 'tmux prefix' to do so. In my ~/.tmux.conf I have for window and pane switching:
# set pane switching with <alt>{U, E, N, I} for up, down, left, right and respectively without needing prefix
bind -n M-N select-pane -L
bind -n M-I select-pane -R
bind -n M-U select-pane -U
bind -n M-E select-pane -D
# set window switching without needing prefix
bind -n M-a select-window -t :1
bind -n M-r select-window -t :2
bind -n M-s select-window -t :3
bind -n M-t select-window -t :4
bind -n M-d select-window -t :5
bind -n M-h select-window -t :6
You can just replace the keybindings I chose like M-a (alt-a) to something that works for you. If you want to keep using a prefix (incase you are worried the keybindings will clash with other program/system bindings), remove the '-n' flag. Hope that helps.
If it doesn't here is a tutorial I found from a google search: http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multip...
and IMO a really good book on Tmux if you decide to dive in more: http://www.amazon.com/tmux-Productive-Mouse-Free-Development...
I also did the thing to get rid of the tmux prefix for pane switching. But since I don't use the function keys, I mapped keys F1 through F9 to various tmux functions. F1 = next pane, F2 = prev pane. One less key to press. :)
It binds the function keys which makes life so much easier. F2 starts new window, F3 and F4 rotate back and forwards. It also has a pretty neat status line.
This is exactly the functionality I was looking for back when it didn't exist. It wasn't immediately obvious how to use this, but here's how:
bind-key -t vi-copy 'y' copy-pipe "redis-cli -x set status"
set-option -g status-right '#(redis-cli --raw get status)'
And now I have a message I just copied to redis in my tmux status bar. I'm planning on doing this with clipboard text next.
with several sessions running on most of my machines, i frequently found myself `detaching` and `reattaching` to a different session... as the `choose-session` command gives you a full list of all the windows, which tends to obfuscate exactly what's going on, particularly if you have a bunch of sessions and windows..
however, the `choose-tree` gives you a session tree, which you can expand and easily identify... meaning that instead of sending `^a d`, followed by tmux attach sessionname you can comfortably do a `^a s` and get where you want to be (presuming you've remapped ^b to ^a)
also, you should be using the tmux buffers, `^a =`!
†) or rather not builtin zmodem-support but generic "run this program with stdin/stdout connected directly to the device" like cu's ~+ escape.
byobu is really recommended because its simple to use yet powerfull.
You might need: 'apt-get install libevent-dev' as a prerequisite.
pushd /tmp && \
wget 'http://downloads.sourceforge.net/project/tmux/tmux/tmux-1.8/tmux-1.8.tar.gz?r=http%3A%2F%2Ftmux.sourceforge.net%2F&ts=1364579710&use_mirror=garr' && \
gunzip < tmux-1.8.tar.gz | tar -vx && \
cd tmux-1.8 && \
./configure --prefix=~/installs/tmux-1.8 && \
mkdir ~/installs && \
make && \
make install && \
popd pushd /tmp && \
curl 'http://downloads.sourceforge.net/project/tmux/tmux/tmux-1.8/tmux-1.8.tar.gz?r=http%3A%2F%2Ftmux.sourceforge.net%2F&ts=1364579710&use_mirror=garr'| tar xvf && \
cd tmux-1.8 && \
./configure --prefix=~/installs/tmux-1.8 && \
mkdir ~/installs && \
make && \
make install && \
popd rm -rf ~/installs/tmux-1.8I guess I assume that if you want cutting-edge packages you'll use a cutting-edge release/distribution. If you don't, and you want something more recent then it seems to make sense to make your own packages, or install locally via gnu-stow, or similar.