#author("2021-05-13T08:55:36+09:00","default:nobuoki","nobuoki") #author("2021-05-21T08:26:33+09:00","default:nobuoki","nobuoki") - 2021/05/12 サーバ側のコマンド修正 - 2021/05/13 事例追加 * TL;DR [#s7222f2e] ** サーバ側 [#v9e044e4] # テキストを投げ込まれたらクリップボードに書き込む(windows + MSYS2) socat tcp-listen:7000,fork,reuseaddr /dev/clipboard & # あるいはこれでも動く while true; do socat tcp-listen:7000 /dev/clipboard || break; done & ** クライアント側 [#yd0d144a] # クリップボードを取り出す socat tcp-connect:192.168.33.1:7000 stdout | cat -n # tmuxのバッファをクリップボードに投げつける tmux save-buffer - | socat stdin tcp-connect:192.168.33.1:7000 # ファイルを投げつける socat tcp-connect:192.168.33.1:7000 path/to/file こういうエイリアスを作っておくと非常に便利 alias pbcopy='socat stdin tcp-connect:192.168.33.1:7000' alias pbpaste='socat tcp-connect:192.168.33.1:7000 stdout' * 何が出来るのか? [#l973c40d] - linuxやMacから、WindowsPCにテキストを投げつける - WindowsPCは受け取ったテキストをクリップボードに書き込む * いつ役に立つのか? [#tcc0ea57] - 母艦でVMをheadlessモードでCLIで操作している - 母艦からsshでVMに繋ぎ、VM側でtmuxを動かしている という、かなりレアな場合に便利かもしれません * 参考 [#g81e25fc] - [[socatを使ってソケットテストする:https://rcmdnk.com/blog/2014/12/03/comptuer-network/]] - [[nc コマンドで簡易HTTPサーバ:http://blog.livedoor.jp/sonots/archives/34703829.html]] * 追伸 [#qaa8bcb2] mintty を使っている場合、こんなことしなくても ~/.minttyrc に1行追加すれば良い AllowSetSelection=true - [[Copy console text in tmux:https://github.com/mintty/wsltty/issues/21]] - [[Cygwin (mintty) でサーバ上で実行しているtmuxからマウス選択範囲をコピー:https://qiita.com/kesoji/items/7f6264f5a4c4e354f9f2]]