Tmux:将键发送到特定窗格,即使在更改布局后也是如此
Tmux: send-key to a specific pane, even after changing the layout
编写 tmux 脚本(在 vim 函数中,但可以应用于简单的 bash 脚本),例如,我可以使用 -t 1 轻松地将命令发送到目标窗格。
这工作正常,只要我不更改 windows.
的布局
function! RunPython()
let pycmd = systemlist('command -v python')[0]
let filename = expand('%:p')
silent! call system('tmux send-key -t 1 "' . pycmd . ' ' . filename . '" enter;')
endfunction
nnoremap <leader>p :call RunPython()<CR>
如果我切换布局(例如,使用 Ctrl+b、Ctrl+o),此 -t 1 将停止工作,因为窗格 1 将变为窗格 0,反之亦然。
有没有办法 refers/target 到特定窗格,无论它去到哪里或移动到哪里?类似于 referring/targeting a window?
找了几天,没找到。
干杯。
我有一段时间没有使用 tmux(终于切换到平铺 wm)但是,我认为您可以尝试使用 tmux 窗格的 Mark
功能。它基本上允许您“标记”一个面板(无论其位置如何)然后调用它;这也许对你有帮助吗?
因为我已经有一段时间没有使用这个了,如果这个信息有误请告诉我(不是在机器前w/tmux测试这个atm ).
来自 tmux 手册页:
Sessions, window and panes are each numbered with a unique ID; session
IDs are prefixed with a ‘$’, windows with a ‘@’, and panes with a ‘%’.
These are unique and are unchanged for the life of the session, window
or pane in the tmux server.
因此,要获取窗格的 ID,您可以执行以下操作:
tmux display-message -p "#{pane_id}"
然后使用任何 pane_id 号码(前面有 %
)发送您的
keys - 假设 pane_id 是 '2',那么:
tmux send-keys -t %2 'echo hello world' ^M
编写 tmux 脚本(在 vim 函数中,但可以应用于简单的 bash 脚本),例如,我可以使用 -t 1 轻松地将命令发送到目标窗格。 这工作正常,只要我不更改 windows.
的布局function! RunPython()
let pycmd = systemlist('command -v python')[0]
let filename = expand('%:p')
silent! call system('tmux send-key -t 1 "' . pycmd . ' ' . filename . '" enter;')
endfunction
nnoremap <leader>p :call RunPython()<CR>
如果我切换布局(例如,使用 Ctrl+b、Ctrl+o),此 -t 1 将停止工作,因为窗格 1 将变为窗格 0,反之亦然。
有没有办法 refers/target 到特定窗格,无论它去到哪里或移动到哪里?类似于 referring/targeting a window?
找了几天,没找到。
干杯。
我有一段时间没有使用 tmux(终于切换到平铺 wm)但是,我认为您可以尝试使用 tmux 窗格的 Mark
功能。它基本上允许您“标记”一个面板(无论其位置如何)然后调用它;这也许对你有帮助吗?
因为我已经有一段时间没有使用这个了,如果这个信息有误请告诉我(不是在机器前w/tmux测试这个atm ).
来自 tmux 手册页:
Sessions, window and panes are each numbered with a unique ID; session IDs are prefixed with a ‘$’, windows with a ‘@’, and panes with a ‘%’. These are unique and are unchanged for the life of the session, window or pane in the tmux server.
因此,要获取窗格的 ID,您可以执行以下操作:
tmux display-message -p "#{pane_id}"
然后使用任何 pane_id 号码(前面有 %
)发送您的
keys - 假设 pane_id 是 '2',那么:
tmux send-keys -t %2 'echo hello world' ^M