gpakosz / .tmux

🇫🇷 Oh my tmux! My self-contained, pretty & versatile tmux configuration made with ❤️
MIT License
21.79k stars 3.36k forks source link

vim paste function not woking properly in tmux #754

Closed atomwh closed 1 month ago

atomwh commented 1 month ago

About enviroment: OS: ubuntu 22.04 tmux version: 3.2a (and I also tried latest 3.4, it doesn't work neither) vim version: 8.2.3995

when I am trying to paste something into vim in Insert Mode, I got something weired

  1. paste "install", it will become Nstall
  2. paste "helloworld", it will become "\nWorld"
  3. paste "stormteststr", it will become "Tormteststr"
  4. Exsiting content is "123456", when I paste with content "issue"(in insert mode at the end of line using shift+insert), it will become "1ssue23456"
  5. Exsiting content is "123456", when I paste with content "And helloworld", it will become "123456nd helloworld"

Even if in normal mode when I want to search something, after input "/", I press shift+insert, what I expected is that the text will show following the "/", and then press "enter" I can search the text. But what I got is that the text directly paste into the file content

I have tried things below:

  1. clear .vimrc, issue still exists
  2. clear some content of .tmux.conf, issue solved
    
    # -- 8< ------------------------------------------------------------------------

%if #{==:#{TMUX_PROGRAM},}
run 'TMUX_PROGRAM="$(LSOF=$(PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command -v lsof); $LSOF -b -w -a -d txt -p #{pid} -Fn 2>/dev/null | perl -n -e "if (s/^n((?:.(?!dylib$|so$))+)$/\1/g && s/(?:\s+([^\s]+?))?$//g) { print; exit } } exit 1; {" || readlink "/proc/#{pid}/exe" 2>/dev/null)"; {[ -f "$TMUX_PROGRAM" ] && [ -x "$TMUX_PROGRAM" ]} || TMUX_PROGRAM="$(command -v tmux || printf tmux)"; "$TMUX_PROGRAM" -S #{socket_path} set-environment -g TMUX_PROGRAM "$TMUX_PROGRAM"' %endif
%if #{==:#{TMUX_SOCKET},}
run '"$TMUX_PROGRAM" -S #{socket_path} set-environment -g TMUX_SOCKET "#{socket_path}"' %endif
%if #{==:#{TMUX_CONF},}
run '"$TMUX_PROGRAM" set-environment -g TMUX_CONF $(for conf in "$HOME/.tmux.conf" "$XDG_CONFIG_HOME/tmux/tmux.conf" "$HOME/.config/tmux/tmux.conf"; do [ -f "$conf" ] && printf "%s" "$conf" && break; done)' %endif
%if #{==:#{TMUX_CONF_LOCAL},}
run '"$TMUX_PROGRAM" set-environment -g TMUX_CONF_LOCAL "$TMUX_CONF.local"'
%endif

run '"$TMUX_PROGRAM" source "$TMUX_CONF_LOCAL"'
run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'

############ clear start here and util the end of .tmux.conf ################

EOF

exit the script if any statement returns a non-true return value

gpakosz commented 1 month ago

Hello @atomwh 👋

How are you pasting? This is more than likely unrelated to Oh my tmux!

atomwh commented 1 month ago

Hello

Thanks for your reply

How are you pasting?

I am using shift-insert and mouse right click, both have the issue. My terminal application is xshell

This is more than likely unrelated to Oh my tmux!

Indeed, my first thought was that it was a problem with vim, but I cleared all the custom configurations in vimrc, and the issue still existed. Then I tried to operate directly in the ssh terminal without opening tmux, and pasting works normally, so I suspected that it was a issue with tmux. I also tried to remove .tmux.conf and .tmux.conf.local(installedd following the guide of this repository) in $HOME directory, and pasting works normally. And as I wrote in the issue, when I cleared some part of the .tmux.conf(line 156 to the end), pasting could work normally.

Your tmux config was great, if I have to remove some part of .tmux.conf, some function lost like status bar. So I raised this issue hoping you can help to solve it, thank you.

gpakosz commented 1 month ago

What's the value of TERM when you're inside tmux and using Oh my tmux!?

atomwh commented 1 month ago

What's the value of TERM when you're inside tmux and using Oh my tmux!?

it was tmux-256color, and in ssh terminal it was xterm.

I triedexport TERM=xterm, pasting got working normally. Any suggestion for TERM setting?

Thanks

gpakosz commented 1 month ago

TERM being set to tmux-256color means that the computer where tmux runs supports that description.

However you mentioned xshell, which I don't know, but seems to be a terminal emulator + ssh client that runs on Windows. And I believe xshell doesn't support tmux-256color.

I don't know if xshell supports the equivalent of adding this line to ~/.ssh/config when the client is running on Linux or macOS

SetEnv TERM=xterm-256color

Something else you can do is, on the server side, uncomment this line from your .local customization file

set -g default-terminal "screen-256color" #!important
gpakosz commented 1 month ago

From within a tmux pane, can you please also share the output of the env command? (Redact as necessary)

atomwh commented 1 month ago

Thanks for your advices about TERM setting.

And below was my env output within tmux

SHELL=/bin/sh
NVM_INC=/home/storm/.nvm/versions/node/v18.19.0/include/node
TERM_PROGRAM_VERSION=3.4
TMUX_CONF=/home/storm/.tmux.conf
TMUX=/tmp/tmux-997/default,3257234,0
EDITOR=vim
PWD=/home/storm
LOGNAME=storm
XDG_SESSION_TYPE=tty
MOTD_SHOWN=pam
HOME=/home/storm
LANG=en_US.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
TMUX_CONF_LOCAL=/home/storm/.tmux.conf.local
SSH_CONNECTION=172.20.1.17 2009 172.20.1.220 22
NVM_DIR=/home/storm/.nvm
LESSCLOSE=/usr/bin/lesspipe %s %s
XDG_SESSION_CLASS=user
TERM=tmux-256color
LESSOPEN=| /usr/bin/lesspipe %s
LIBVIRT_DEFAULT_URI=qemu:///system
USER=storm
TMUX_PANE=%0
TMUX_SOCKET=/tmp/tmux-997/default
DISPLAY=localhost:10.0
SHLVL=2
NVM_CD_FLAGS=
XDG_SESSION_ID=1538
TMUX_PROGRAM=/home/storm/.local/bin/tmux
LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda/lib64
XDG_RUNTIME_DIR=/run/user/997
SSH_CLIENT=172.20.1.17 2009 22
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
PATH=/home/storm/.local/bin:/home/storm/.local/bin:/home/storm/tools/clang/clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04/bin:/usr/local/cuda/bin:/home/storm/.local/bin:/home/storm/.cargo/bin:/home/storm/.local/bin:/home/storm/tools/clang/clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04/bin:/home/storm/.nvm/versions/node/v18.19.0/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/997/bus
NVM_BIN=/home/storm/.nvm/versions/node/v18.19.0/bin
SSH_TTY=/dev/pts/0
TERM_PROGRAM=tmux
_=/usr/bin/env
atomwh commented 1 month ago

Something else you can do is, on the server side, uncomment this line from your .local customization file

set -g default-terminal "screen-256color" #!important

After adding this line to .tmux.conf.local, it works, the TERM variable turn into screen-256color and pasting works well.

Thank you :-)

gpakosz commented 1 month ago

Looking at the output of env, unfortunately there's nothing that could help detect xshell