Edit tmux output with Vim (or any text editor)

acro5piano

Kay Gosho

Posted on March 19, 2019

Edit tmux output with Vim (or any text editor)

image

We can scroll tmux output with C-b [ by default, and it provides vim like key binding.

However, some bindings are different from my customized vim.

So I add some scripts and settings to open tmux output with Vim (or any other text editor).

Fortunately, tmux has a nice command capture-pane!



#!/bin/bash

# $HOME/bin/vim-edit-tmux-output

file=`mktemp`.sh
tmux capture-pane -pS -32768 > $file
tmux new-window -n:mywindow "vim '+ normal G $' $file"


Enter fullscreen mode Exit fullscreen mode

chmod +x $HOME/bin/vim-edit-tmux-output



# $HOME/.tmux.conf

setenv -g PATH "$HOME/bin:$PATH"
set-option -g history-limit 20000

bind-key C-e run-shell "vim-edit-tmux-output"


Enter fullscreen mode Exit fullscreen mode

Then press C-b C-e and you can open your tmux output!

Another nice feature is that tmux automatically closes the new pane for Vim after quiting vim.

💖 💪 🙅 🚩
acro5piano
Kay Gosho

Posted on March 19, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related