diff --git a/.gitmodules b/.gitmodules index c88c38b7..c501295c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,3 +11,6 @@ [submodule "zsh/zplug"] path = zsh/zplug url = https://github.com/zplug/zplug +[submodule "zsh/is_mosh"] + path = zsh/is_mosh + url = https://github.com/wookayin/is_mosh diff --git a/install.py b/install.py index 0dbe5865..8d0a77f7 100755 --- a/install.py +++ b/install.py @@ -47,6 +47,7 @@ # Bins '~/.local/bin/dotfiles' : 'bin/dotfiles', '~/.local/bin/fasd' : 'zsh/fasd/fasd', + '~/.local/bin/is_mosh' : 'zsh/is_mosh/is_mosh', '~/.local/bin/imgcat' : 'bin/imgcat', '~/.local/bin/imgls' : 'bin/imgls', '~/.local/bin/fzf' : '~/.fzf/bin/fzf', # fzf is at $HOME/.fzf diff --git a/tmux/tmux.conf b/tmux/tmux.conf index c8bbd0ac..25132a19 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -150,7 +150,8 @@ set-window-option -g display-panes-time 1500 set -g focus-events on # Color and Themes -set-option -g default-terminal "screen-256color" +set-option -g default-terminal "xterm-256color" +set-option -ga terminal-overrides ",xterm-256color:Tc" # True-color (24bit) # let pane/window numbers be 1-indexed set-option -g base-index 1 diff --git a/vim/vimrc b/vim/vimrc index 8a8175e6..a4e58899 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -341,7 +341,11 @@ xnoremap ag y:Ag " nmap cd :cd %:p:h " r : screen sucks, redraw everything -nnoremap r :redraw! +function! Redraw() + redraw! + call s:auto_termguicolors() " re-detect true colors +endfunction +nnoremap r :call Redraw() " src : source ~/.vimrc nnoremap src :source ~/.vimrc @@ -428,9 +432,41 @@ if &term =~ '256color' set t_ut= endif +" 24-bit true color: neovim 0.1.5+ / vim 7.4.1799+ +" enable ONLY if TERM is set valid and it is NOT under mosh +function! s:is_mosh() + let output = system("is_mosh -v") + if v:shell_error + return 0 + endif + return !empty(l:output) +endfunction + +function s:auto_termguicolors() + if !(has("termguicolors")) + return + endif + + if (&term == 'xterm-256color' || &term == 'nvim') && !s:is_mosh() + set termguicolors + else + set notermguicolors + endif +endfunction +call s:auto_termguicolors() + + " apply base theme silent! colorscheme xoria256 +" airline theme: status line and tab line +if &termguicolors + let g:airline_theme='deus' +else + let g:airline_theme='bubblegum' +endif + + " override more customized colors highlight StatusLine ctermfg=LightGreen highlight ColorColumn ctermbg=52 guibg=#5f0000 @@ -444,6 +480,18 @@ highlight Constant ctermfg=204 guifg=#ff5f87 highlight PreProc ctermfg=219 guifg=#ffafff highlight SpecialKey ctermfg=242 guifg=#666666 +" colors for gui/24bit mode {{ +" DiffAdd - inserted lines (dark green) +highlight DiffAdd guibg=#102a05 guifg=NONE +" DiffDelete - deleted/filler lines (gray 246) +highlight DiffDelete guibg=#949494 +" DiffChange - changed lines (dark red) +highlight DiffChange guibg=#471515 guifg=NONE +" DiffChange - changed 'text'(brighter red) +highlight DiffText guibg=#721b1b guifg=NONE +" }} + + " no underline, current cursor line highlight CursorLine cterm=none @@ -489,8 +537,8 @@ autocmd BufWinLeave * call clearmatches() autocmd InsertLeave * silent! set nopaste " better popup menu colors (instead of dark black) -highlight Pmenu ctermfg=black ctermbg=yellow -highlight PmenuSel ctermfg=red ctermbg=white gui=bold +highlight Pmenu ctermfg=black ctermbg=yellow guifg=black guibg=#ffec99 +highlight PmenuSel ctermfg=red ctermbg=white guifg=red guibg=white gui=bold " http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor function! ShowSyntaxGroup() @@ -626,9 +674,9 @@ let g:EditorConfig_core_mode = 'python_external' " ---------------------------------------------------------------- }}} " Airline {{{ +" Note: for airline theme, see the 'appearance' section " use airline, with powerline-ish theme -let g:airline_theme='bubblegum' let g:airline_powerline_fonts=1 " enable tabline feature diff --git a/zsh/is_mosh b/zsh/is_mosh new file mode 160000 index 00000000..6cde1cf5 --- /dev/null +++ b/zsh/is_mosh @@ -0,0 +1 @@ +Subproject commit 6cde1cf5d4af45b2f9bcc4267d0beca0b2b61c17 diff --git a/zsh/zshrc b/zsh/zshrc index 8a3ded6b..8c169992 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -86,12 +86,8 @@ zplug load #--verbose for config_file (${ZDOTDIR:-$HOME}/.zsh/zsh.d/*.zsh(N)) source $config_file # Terminal -# screen-256color if inside tmux, xterm-256color otherwise -if [[ -n "$TMUX" ]]; then - export TERM="screen-256color" -else - export TERM="xterm-256color" -fi +# Use xterm-256color (for tmux, too) +export TERM="xterm-256color" # iTerm integration (for OS X iTerm2) # @see https://iterm2.com/shell_integration.html