From 1b4145b1d1debe2e0c92e4db7af5f1437fa9d0c5 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 19 Jul 2019 02:36:43 +0300 Subject: [PATCH] .vimrc: Change cursor shape under GNU `screen` --- .shellrc | 8 +------- .vimrc | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.shellrc b/.shellrc index af5408c..d9a2085 100644 --- a/.shellrc +++ b/.shellrc @@ -327,10 +327,6 @@ mc() { case "$TERM" in screen*) # screen, screen.rxvt - if [ "$TERM" = screen.rxvt ]; then - MC_SAVE_TERM="$TERM" - TERM=rxvt - fi MC_XTERM="-x" ;; esac @@ -382,9 +378,7 @@ mc() { fi [ -n "$MC_SAVE_OPS1" ] && OPS1="$MC_SAVE_OPS1" - [ -n "$MC_SAVE_TERM" ] && TERM="$MC_SAVE_TERM" - unset MC_FOUND MC_PWD_FILE MC_SAVE_OPS1 MC_SAVE_TERM \ - MC_SLOW MC_TMP_DIR MC_XTERM + unset MC_FOUND MC_PWD_FILE MC_SAVE_OPS1 MC_SLOW MC_TMP_DIR MC_XTERM return $rc } diff --git a/.vimrc b/.vimrc index 41d0e22..7613cfd 100644 --- a/.vimrc +++ b/.vimrc @@ -299,21 +299,29 @@ else cmap "https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode - function! WrapForTmux(s) - if !exists('$TMUX') - return a:s - endif + " https://ttssh2.osdn.jp/manual/en/usage/tips/vim.html + function! WrapForScreenTmux(s) + if (&term =~ "screen") + let scr_start = "\P" + let scr_end = "\\\" - let tmux_start = "\Ptmux;" - let tmux_end = "\\\" + return scr_start . a:s . scr_end + endif + + if exists('$TMUX') + let tmux_start = "\Ptmux;" + let tmux_end = "\\\" + + return tmux_start . substitute(a:s, "\", "\\", 'g') . tmux_end + endif - return tmux_start . substitute(a:s, "\", "\\", 'g') . tmux_end + return a:s endfunction " https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes - let &t_EI.=WrapForTmux("\e[2 q") "EI = NORMAL mode (ELSE) - let &t_SI.=WrapForTmux("\e[6 q") "SI = INSERT mode - let &t_SR.=WrapForTmux("\e[4 q") "SR = REPLACE mode + let &t_EI.=WrapForScreenTmux("\e[2 q") "EI = NORMAL mode (ELSE) + let &t_SI.=WrapForScreenTmux("\e[6 q") "SI = INSERT mode + let &t_SR.=WrapForScreenTmux("\e[4 q") "SR = REPLACE mode "Cursor settings: " 1 -> blinking block -- 2.39.5