6
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

tmuxやvimで分割された画面の背景色をフォーカスの有無で変更する。

Last updated at Posted at 2018-12-04

はじめに

自分が今どこにいるのか、わからなくなることが多いので。

tmux

2018-12-04_11:40:30.png

tmux.conf
setw -g window-active-style fg='#c0c5ce',bg='#2b303b'
setw -g window-style fg='#c0c5ce',bg='#27292d'
tmux.conf
setw -g window-active-style fg='#c0c5ce',bg='#2b303b'
setw -g window-style fg='#c0c5ce',bg='#ef5a4a'

,

vim

2018-12-04_11:38:15.png

init.vim
augroup ChangeBackground
  autocmd!
  autocmd WinEnter * highlight Normal guibg=default
  autocmd WinEnter * highlight NormalNC guibg='#27292d'
augroup END
init.vim
augroup ChangeBackground
  autocmd!
  autocmd WinEnter * highlight Normal guibg=default
  autocmd WinEnter * highlight NormalNC guibg='#ef5a4a'
augroup END

tmux と vim

2018-12-04_11:38:57.png
2018-12-04_11:39:00.png

init.vim
augroup ChangeBackground
  autocmd!
  autocmd WinEnter * highlight Normal guibg=default
  autocmd WinEnter * highlight NormalNC guibg='#27292d'
  autocmd FocusGained * highlight Normal guibg=default " 追加
  autocmd FocusLost * highlight Normal guibg='#27292d' " 追加
augroup END

denite.nvimでauto_previewする場合

行移動する度にウィンドウが切り替わるので画面がチカチカします。なので、buffersに[denite]があるならハイライトを切り替えないようにします。

init.vim
function! s:changeBackground()
  for buf in getbufinfo()
    if buf.name =~ '\[denite\]$'
      return
    endif
  endfor
  highlight Normal guibg=default
  highlight NormalNC guibg='#27292d'
endfunction

augroup ChangeBackground
  autocmd!
  autocmd WinEnter * call s:changeBackground()
  autocmd FocusGained * highlight Normal guibg=default
  autocmd FocusLost * highlight Normal guibg='#27292d'
augroup END
6
8
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?