Embed your vim statusline in the tmux statusline!
Using vim-plug:
Plug 'vimpostor/vim-tpipeline'
It is highly recommended to put this in your ~/.tmux.conf
:
set -g focus-events on
set -g status-style bg=default
set -g status-left-length 90
set -g status-right-length 90
set -g status-justify centre
Restart tmux and now you should see your vim statusline inside tmux.
vim-tpipeline
is compatible with all statuslines and can be used together with other statusline plugins like lualine. If it doesn't work with yours, file a bug report.
- Vim 8.2.4650 (or higher) OR Neovim 0.6 (or higher)
- True color support (
set termguicolors
in vim) - For best experience use a terminal that supports focus events (Known good terminals are
wezterm
,konsole
andiTerm2
)
This plugin will automatically embed your statusline in tmux with sane defaults.
If you want to have more control over where it is placed, disable the autoconfiguration with g:tpipeline_autoembed
and embed the statusline manually, here is one example:
" .vimrc
" You can also use Lua for configuration, see :h lua-vim-variables for help
let g:tpipeline_autoembed = 0
# .tmux.conf
set -g focus-events on
set -g status-style bg=default
set -g status-left '#(cat #{socket_path}-\#{session_id}-vimbridge)'
set -g status-left-length 90
set -g status-right '#(cat #{socket_path}-\#{session_id}-vimbridge-R)'
set -g status-right-length 90
set -g status-justify centre
By default vim-tpipeline
will copy your standard vim statusline
.
If you want to use a different statusline just for tmux, you can set it manually:
" tpipeline comes bundled with its own custom minimal statusline
let g:tpipeline_statusline = '%!tpipeline#stl#line()'
" You can also use standard statusline syntax, see :help stl
let g:tpipeline_statusline = '%f'
There are many more options available to accomodate for every specific usecase. Check them out in the comprehensive help file using :help tpipeline-configure
.
Usually there is plenty of empty space available in your tmux statusline, hence you make much better use of your space if you put your vim statusline there. After all you don't want to have your carefully handcrafted vim config end up as a bad Internet Explorer meme, do you?
Yes, use set stl=%!tpipeline#stl#line()
in your ~/.vimrc
. In fact this plugin uses Vim's autoload mechanism to lazily load features, i.e. if you don't use tmux, you can still use the statusline inside vim without loading unnecessary features.
Besides putting set -g focus-events on
in your tmux
config, you also need to have the XT
-capability available, which you can test by issuing the tput XT
command. If the capability is not present inside tmux, then there are three ways to fix the issue:
- Put
set -g default-terminal "xterm-256color"
in yourtmux
config. - Force vim to enable it by using this in your
.vimrc
let &t_fe = "\<Esc>[?1004h"
let &t_fd = "\<Esc>[?1004l"
- Write your own custom terminfo entry based on tmux-256color
Since tmux version 3.2 you can use absolute-centre
instead of centre
:
-set -g status-justify centre
+set -g status-justify absolute-centre
Why should I use this plugin over onestatus?
- In
onestatus
the tmux statusline is updated using a blocking call, whereastpipeline
uses non-blocking jobs to asynchronously update the statusline. tpipeline
works out of the box with your current vim statusline, whereasonestatus
does not actually use your statusline at all and requires you to configure its own statusline.- As a result of the above,
onestatus
isn't able to use many vim features such as your vim colorscheme and requires you to redefine your colors. Intpipeline
, vim colors are translated to tmux syntax automatically. - Simple things such as showing your current mode or linenumber require writing your own function in
onestatus
. Intpipeline
this works out of the box.