Skip to content

Commit

Permalink
Add UpdateTmuxlineByMode() function
Browse files Browse the repository at this point in the history
  • Loading branch information
g6ai committed Aug 8, 2021
1 parent 66985bd commit 665697f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tmux/update_display_tmuxline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tmux list-panes -s -F "#{session_name}:#{window_index}.#{pane_index} #{pane_curr
tmux send-keys -t ${pane_fields[0]} "export DISPLAY=$DISPLAY" Enter
elif [[ "${pane_fields[1]}" == *[V,v]im* ]]; then
tmux send-keys -t ${pane_fields[0]} Escape
tmux send-keys -t ${pane_fields[0]} ":Tmuxline airline" Enter
tmux send-keys -t ${pane_fields[0]} ":call UpdateTmuxlineByMode()" Enter
tmux send-keys -t ${pane_fields[0]} ":let \$DISPLAY = \"$DISPLAY\"" Enter
#tmux send-keys -t ${pane_fields[0]} ":xrestore" Enter
fi
Expand Down
32 changes: 31 additions & 1 deletion vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,37 @@ elseif flag == "good"
augroup update_tmuxline
autocmd!
if exists('$TMUX')
autocmd FocusGained * Tmuxline airline
function! UpdateTmuxlineByMode()
let current_mode = mode()
if current_mode ==# 'i'
Tmuxline airline_insert
elseif current_mode ==# 'v'
Tmuxline airline_visual
elseif current_mode ==# 'V'
Tmuxline airline_visual
elseif current_mode ==# 'CTRL-V'
Tmuxline airline_visual
else
Tmuxline airline
endif
endfunction
function! UpdateTmuxlineVisualEnter()
set updatetime=0
call UpdateTmuxlineByMode()
return ''
endfunction
function! UpdateTmuxlineVisualLeave()
set updatetime=4000
call UpdateTmuxlineByMode()
endfunction
autocmd FocusGained * call UpdateTmuxlineByMode()
autocmd InsertEnter * Tmuxline airline_insert
autocmd InsertLeave * Tmuxline airline
vnoremap <silent> <expr> <SID>UpdateTmuxlineVisualEnter UpdateTmuxlineVisualEnter()
nnoremap <silent> <script> v v<SID>UpdateTmuxlineVisualEnter<left><right>
nnoremap <silent> <script> V V<SID>UpdateTmuxlineVisualEnter<left><right>
nnoremap <silent> <script> <C-v> <C-v><SID>UpdateTmuxlineVisualEnter<left><right>
autocmd CursorHold * call UpdateTmuxlineVisualLeave()
endif
augroup END

Expand Down

0 comments on commit 665697f

Please sign in to comment.