Giter VIP home page Giter VIP logo

tmuxline.vim's Introduction

tmuxline.vim

Simple tmux statusline generator with support for powerline symbols and vim/airline/lightline statusline integration

img

img

Features

  • use vim/vim-airline/lightline.vim colors, so tmux and vim share the same statusline colortheme
  • preloaded with stock themes and presets, which can be combined anyway you want
  • configure tmux statusline using a simple hash, in case stock presets don't meet your needs
  • create a snapshot .conf file which can be sourced by tmux, no need to open vim to set your tmux statusline

Quickstart

use vim's statusline colors

Use one of the vim_statusline_* themes (and optionally set in vimrc let g:tmuxline_powerline_separators = 0):

:Tmuxline vim_statusline_1
" or
:Tmuxline vim_statusline_2
" or
:Tmuxline vim_statusline_3

img

use vim-airline colors

Just start vim inside of tmux. airline's colors will be applied to tmux's statusline

img

Alternatively, you can set it manually using airline_* themes:

:Tmuxline airline
" or
:Tmuxline airline_insert
" or
:Tmuxline airline_visual

If you set airline theme manually, make sure the airline-tmuxline extension is disabled, so it doesn't overwrite the theme:

let g:airline#extensions#tmuxline#enabled = 0

use lightline.vim colors

Use one of the lightline_* themes:

:Tmuxline lightline
" or
:Tmuxline lightline_insert
" or
:Tmuxline lightline_visual

img

Usage

Set a a colortheme and a preset, both arguments are optional

:Tmuxline [theme] [preset]

After running :Tmuxline, create a snapshot file which can be sourced by tmux.conf on startup

:TmuxlineSnapshot [file]

Source the created snapshot in tmux.conf

# in tmux.conf
source-file [file]

# alternatively, check file exists before sourcing it in tmux.conf
if-shell "test -f [file]" "source [file]"

Note that :Tmuxline and :TmuxlineSnapshot are available only when vim is inside a tmux session.

Configuration

Stock preset

Set g:tmuxline_preset to a stock preset and run :Tmuxline

let g:tmuxline_preset = 'nightly_fox'
" or
let g:tmuxline_preset = 'full'
" or
let g:tmuxline_preset = 'tmux'
" other presets available in autoload/tmuxline/presets/*

Custom preset

Contents of the statusline are configured with a simple hash. Left section is configured with a, b, c, right with x, y, z. cwin and win affect the current (active) window and the in-active windows respectively.

let g:tmuxline_preset = {
      \'a'    : '#S',
      \'b'    : '#W',
      \'c'    : '#H',
      \'win'  : '#I #W',
      \'cwin' : '#I #W',
      \'x'    : '%a',
      \'y'    : '#W %R',
      \'z'    : '#H'}

img

tmux will replace #X and %X. Excerpts from tmux man page:

#H    Hostname of local host
#h    Hostname of local host without the domain name
#F    Current window flag
#I    Current window index
#S    Session name
#W    Current window name
#(shell-command)  First line of the command's output

string will be passed through strftime(3) before being used.

If the values of the hash g:tmuxline_preset hold an array, a powerline separator will be placed.

let g:tmuxline_preset = {
      \'a'    : '#S',
      \'win'  : ['#I', '#W'],
      \'cwin' : ['#I', '#W', '#F'],
      \'y'    : ['%R', '%a', '%Y'],
      \'z'    : '#H'}

img

tmux allows using any command in the statusline.

let g:tmuxline_preset = {
      \'a'    : '#S',
      \'c'    : ['#(whoami)', '#(uptime | cut -d " " -f 1,2,3)'],
      \'win'  : ['#I', '#W'],
      \'cwin' : ['#I', '#W', '#F'],
      \'x'    : '#(date)',
      \'y'    : ['%R', '%a', '%Y'],
      \'z'    : '#H'}

img

Separators

Use let g:tmuxline_powerline_separators = 0 to disable using powerline symbols

To fine-tune the separators, use g:tmuxline_separators:

let g:tmuxline_separators = {
    \ 'left' : '',
    \ 'left_alt': '>',
    \ 'right' : '',
    \ 'right_alt' : '<',
    \ 'space' : ' '}

Theme

Note that vim-airline has a tmuxline extension which by default sets airline's color theme onto tmuxline. If you don't want airline colors in tmuxline, set let g:airline#extensions#tmuxline#enabled = 0 in vimrc.

Modifying g:tmuxline_theme (details below) makes sense only if the airline-tmuxline is not enabled.

Use g:tmuxline_theme to configure the theme. g:tmuxline_theme can hold either a string (stock theme) or a hash (custom theme).

let g:tmuxline_theme = 'icebert'
" or
let g:tmuxline_theme = 'zenburn'
" or
let g:tmuxline_theme = 'jellybeans'
" other themes available in autoload/tmuxline/themes/*

Alternatively, g:tmuxline_theme can be used to fine tune a custom theme:

let g:tmuxline_theme = {
    \   'a'    : [ 236, 103 ],
    \   'b'    : [ 253, 239 ],
    \   'c'    : [ 244, 236 ],
    \   'x'    : [ 244, 236 ],
    \   'y'    : [ 253, 239 ],
    \   'z'    : [ 236, 103 ]
    \   'win'  : [ 103, 236 ],
    \   'cwin' : [ 236, 103 ],
    \   'bg'   : [ 244, 236 ],
    \ }
" values represent: [ FG, BG, ATTR ]
"   FG ang BG are color codes
"   ATTR (optional) is a comme-delimited string of one or more of bold, dim, underscore, etc. For details refer to 'message-attr attributes' in tmux man page

Installation

The plugin's files follow the standard layout for vim plugins.

  • Pathogen git clone https://github.com/edkolev/tmuxline.vim ~/.vim/bundle/tmuxline.vim
  • Vundle Bundle 'edkolev/tmuxline.vim'
  • NeoBundle NeoBundle 'edkolev/tmuxline.vim'
  • Vim-Plug Plug 'edkolev/tmuxline.vim'

Inspired by

Rationale

Vimscript wasn't my first choice of language for this plugin. Arguably, bash would have been better suited for this task. I chose vimscript because:

  • its data scructures (arrays, hashes) are better than their bash counterparts (easier to write, to maintain). So maintaining your tmux statusline as a vim hash would be easier
  • vim has (better) package managers

Somewhat-similar plugins:

  • powerline is a great project. Still, my Raspberry Pi chokes while executing python every 2 seconds (I haven't tried powerline's daemon mode). I also find it a bit hard to personalize
  • tmux-powerline doesn't focus on easy customization but on adding extra information (segments) in tmux (gmail, weather, earthquake warnings, etc)

License

MIT License. Copyright (c) 2013-2014 Evgeni Kolev.

tmuxline.vim's People

Contributors

aswild avatar drn avatar edkolev avatar fetzerch avatar firedev avatar greg0ire avatar joeybaker avatar perok avatar raphapr avatar sheparddw avatar stvhwrd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.