Chris Johnsen
  • Member for 11 years, 5 months
  • Last seen more than 2 years ago
  • McKinney, TX
Write all tmux scrollback to a file
182 votes

With tmux 1.5, the capture-pane command accepts -S and -E to specify the start and end lines of the capture; negative values can be used to specify lines from the history. Once you have the data in a ...

View answer
How to create a new window on the current directory in tmux?
Accepted answer
177 votes

Starting in tmux 1.9 the default-path option was removed, so you need to use the -c option with new-window, and split-window (e.g. by rebinding the c, ", and % bindings to include -c '#{...

View answer
How big is the pipe buffer?
Accepted answer
177 votes

The capacity of a pipe buffer varies across systems (and can even vary on the same system). I am not sure there is a quick, easy, and cross platform way to just lookup the capacity of a pipe. Mac OS ...

View answer
Attach to different windows in session
Accepted answer
169 votes

The reason both clients switch windows at the same time is because they are both connected to the same session (the “current window” is an attribute of the session, not the client). What you can do is ...

View answer
Renumbering windows in tmux
123 votes

tmux 1.7 has a couple of features that can help establish and maintain gapless/packed window numbers: The move-window command learned a new -r option that will renumber all the windows in a session (...

View answer
How to insert the result of a command into the text in vim?
Accepted answer
73 votes

You can use the expression register, "=, with p (or P) in normal mode or <C-R> in insert mode: In normal mode: (<C-M> here means Control+M, or just press Enter/Return) "=strftime('%c')&...

View answer
How do I add newlines between lines printed on the command line?
Accepted answer
61 votes

sed G # option: g G Copy/append hold space to pattern space. G is not often used, but is nice for this purpose. sed maintains two buffer spaces: the “pattern space” and the “hold space”. The ...

View answer
what is `env <command>` doing?
Accepted answer
45 votes

This command env name=value name2=value2 program and args runs the command program and args with an environment formed by extending the current environment with the environment variables and values ...

View answer
zsh: excluding files from a pattern
39 votes

zsh has the ^ glob operator when EXTENDED_GLOB is on. It seems like the perfect fit for your stated situation: setopt extendedglob print -rl foo/^type_A* It means “match anything, except what ...

View answer
How do I cycle through panes inside a window in tmux like in screen?
Accepted answer
39 votes

tmux and screen have different models so there is no exact equivalent. In screen terms, a split lets you display multiple windows at the same time. next (C-a n) rotates windows through the active ...

View answer
Is there an equivalent of GNU Screen's "log" command in tmux?
Accepted answer
39 votes

Let me see if I have deciphered your screen configuration correctly: You use something like logfile "%t-screen.log" (probably in a .screenrc file) to configure the name of the log file that will be ...

View answer
How can I paste (overwriting) with vim?
Accepted answer
37 votes

By default, the paste commands use the " (“unnamed”) register. Effectively, any command that writes to a register also writes to the unnamed register, so yanks, deletes, and changes all affect it. ...

View answer
Quoting in ssh $host $FOO and ssh $host "sudo su user -c $FOO" type constructs
Accepted answer
37 votes

Dealing with multiple levels of quoting (really, multiple levels of parsing/interpretation) can get complicated. It helps to keep a few things in mind: Each “level of quoting” can potentially ...

View answer
Create tar archive of a directory, except for hidden files?
Accepted answer
35 votes

You posted in a comment that you are working on a Mac OS X system. This is an important clue to the purpose of these ._* files. These ._* archive entries are chunks of AppleDouble data that contain ...

View answer
tmux disable confirmation prompt on kill-window
Accepted answer
32 votes

By default <Prefix> & is bound to confirm-before -p "kill-window #W? (y/n)" kill-window. The use of confirm-before causes the prompting. If you do not want the confirmation prompt, then just ...

View answer
Github adding a repository as a fork from an existing clone
Accepted answer
29 votes

You can do it all from your existing repository (no need to clone the fork into a new (local) repository, create your branch, copy your commits/changes, etc.). Get your commits ready to be published. ...

View answer
Can I see what's going on in a tmux session without attaching to it?
Accepted answer
26 votes

I think capture-pane might suit your needs: tmux capture-pane -pt "$target-pane" (see “target-pane” in the man page for the ways to specify a pane) By default, that command will dump the current ...

View answer
How to get vim to work with tmux properly?
23 votes

There are several levels of configuration that need to be set up correctly for the best functionality. Configure tmux to recognize the sequences. Before launching tmux, set a TERM value that is ...

View answer
How similar is Apple's terminal.app to a bash terminal on Linux?
Accepted answer
23 votes

Terminal is a terminal emulator. It interprets various control sequences sent by programs (control characters like CR, LF, BS and longer control sequences for commands like “clear screen”, “move ...

View answer
Get TMux scroll buffer contents
Accepted answer
22 votes

With tmux 1.5 (and later), you can give negative numbers to the -S option of capture-pane to access the scroll back buffer. Examples: Capture (up to) 32768 lines of the scroll back buffer along with ...

View answer
How do I redirect output to cd?
Accepted answer
18 votes

You want command substitution, not redirection: cd "$(locate Descargas | grep -F 'Descargas$')" The bits between the $( and the ) are run as a command and the output (stripped of any final newline) ...

View answer
Rebuild auto-complete index (or whatever it's called) and binaries in $PATH cache in zsh
17 votes

If you are having problems getting “argument completion” working for the new commands then compinit is probably the command you need, however it has a caching mechanism that might be causing your ...

View answer
Given keys in ~/.ssh/authorized_keys format, can you determine key strength easily?
Accepted answer
17 votes

ssh-keygen can do the core of the work (generating a fingerprint from a public key), but it will not automatically process a list of multiple keys as is usually found in an authorized_keys file. Here ...

View answer
Execute a specific command in a given directory without cd'ing to it?
16 votes

Some programs have options with which you can tell them to chdir(2) themselves (e.g. GNU tar’s -C/--directory). Outside of such programs though, something will have to chdir. You could write and use ...

View answer
Arrays and loops in zsh
Accepted answer
14 votes

Section 15.2.1 “Array Subscripts” says that arrays can be index with [exp] (where exp is a numeric expression) and that elements start at index 1 (0 if KSH_ARRAYS is set). Section 14.3 “Parameter ...

View answer
Get pane # of each pane in a window from a script?
Accepted answer
14 votes

tmux (since v1.5) provides TMUX_PANE in the environment of the process it launches for a pane; each new pane gets a server-unique value. So, assuming that TMUX_PANE is available in your environment, ...

View answer
Kill a tmux session and select another tmux session
Accepted answer
13 votes

I think this is close to what you want: bind-key X confirm-before -p "Kill #S (y/n)?" "run-shell 'tmux switch-client -n \\\; kill-session -t \"#S\"'" Your #3 approach is along the right lines, but ...

View answer
Shift-arrow not working in emacs within tmux
13 votes

First, make sure your TERM is correct at each location: xterm-something (e.g. xterm-256color) inside your local shell running in your iTerm2 window xterm-something inside your shell after SSHing to ...

View answer
Restoring an option at the end of a function in zsh
Accepted answer
12 votes

You can use the local_options option to automatically restore options when the function exits. This would only be appropriate if your function does not make any other option changes that you intend to ...

View answer
Using Ctrl+[0-9] to cycle between windows using tmux
Accepted answer
11 votes

Several of the Control+digit keystrokes generate fairly standardized sequences, but not all of them do. Here is what I found in the xterm that I had handy: C-1: 1 (i.e. not different form a plain 1 ...

View answer