How to copy from tmux running in putty to windows clipboard

前端 未结 5 629
难免孤独
难免孤独 2021-01-30 11:16

ENV: I am running tmux in putty, on a windows 7 laptop. I do ssh to linux systems while working.

I have to solve two glitches with tmux, before using it for all my needs.

5条回答
  •  情话喂你
    2021-01-30 11:52

    This is absolutely possible. All of the config lines below were copied from machines in different tmux panes back to my Windows machine. Yes, I putty into one machine and tmux and ssh from there to others and can move my vim yanks to any machine, including my Windows browser.

    I do run an X server on Windows (doesn't need to be on Windows, but you need one somewhere).

    Essential ingredients:

    • putty 0.62 (on Windows)
    • tmux 1.8 (on one Linux machine)
    • xclip (on Linux machines)
    • MobaXterm (on Windows for their x server)

    Your network setup might differ a bit, especially on the X server display config but here it goes:

    tmux

    # allow mouse to select panes
    setw -g mode-mouse on
    set-option -g mouse-select-pane on
    
    # allow yank into system clipboard
    #bind C-y run "tmux save-buffer - | xclip -i"
    bind C-y run-shell -b "tmux show-buffer | xclip -selection clipboard -i"
    # move x clipboard into tmux paste buffer
    bind C-p run-shell -b "xclip -o -selection clipboard | tmux load-buffer - ; tmux paste-buffer"
    

    vim

    " get some  autoselect interaction with the system clipboard
    set guioptions=aA
    

    MobaXterm

    I keep this running but don't ever have to run tmux in a xterm shell. Make sure that the shared clipboard is selected in the X11 settings. I suppose xming should work but the settings for my other needs never seemed to work out. MobaXterm has other goodies I like anyway (file browsers etc).

    I suppose I could run ssh session with tmux in MobaXterm but I prefer the putty window where I have my solarized color palette.

    putty

    ssh to the machine with tmux. At this point, I set the DISPLAY environment variable and put it in an env file that is sourced by bash. This way, every subsequent window created will have it set. Setting it on other machines that I hop to from the tmux machine is a separate exercise entirely.

    In any machine that will be sharing the clipboard, make sure you have the proper $DISPLAY set. You should be able to run xeyes and see it on your local machine.

    Everyone will be sharing the clipboard. vim will copy to the clipboard when you yank. To paste in another tmux pane, use the bind-key ctrl-p (ctrl-a ctrl-p for me).

    If it's not working, you can always try xclip -o -selection clipboard to see what should paste. you also will be able to move any "tmux selected" text (mouse or bind-key [) to the clipboard (and thus to a regular windows window) with bind-key ctrl-y (i.e. tmux yank).

提交回复
热议问题