How to get the result of send-keys in tmux?

╄→гoц情女王★ 提交于 2019-12-05 05:33:38

The context of how you are accessing the output will impact whether this solution is better or not, but this might work:

tmux send-keys -t <session:win.pane> '<command>' Enter
tmux capture-pane -t <session:win.pane> 
tmux show-buffer

You should be able to play with the -S, and -E options of capture-pane, as well as the size of the pane, to accurately capture the output. If you're so inclined, you could also use show-panes and a small regexp to capture the height of the pane, and then just use -S <height - 1> to capture just the last line.

It's then simple to read this from another program like so (e.g., in python):

print Popen(['tmux', 'show-buffer'], stdout=PIPE).communicate()[0]

one option is to call a script with send-keys that runs 'show info' and have the script 'send-keys' back the results to the tmux session you are on. this only works if you are in tmux to begin with.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!