将 tmux 选择传递给 shell 命令?

Pass tmux selection to a shell command?

要在 tmux 中进行类似 vim 的无鼠标复制和粘贴,我的 .tmux.conf.

中有这个片段
setw -g mode-keys vi
unbind [
bind Escape copy-mode
unbind p
bind p paste-buffer
bind -t vi-copy v begin-selection
bind -t vi-copy y copy-selection

假设我选择了我感兴趣的文本。现在,我想编辑我的选择,而不是使用 ycopy-selection,并将编辑后的版本回显到本地文件 g

试图将 saveb 的输出通过管道传输到 shell 命令,我尝试了以下操作,但无济于事。

(暂时忘记编辑;只是回应)

bind-key g saveb - | run-shell 'xargs echo > ~/my-selection.txt

我相信你正在寻找 copy-pipe:

bind-key -t vi-copy 'y' copy-pipe "cat > ~/my-selection.txt"