从 .screenrc 在 GNU Screen 窗口中运行命令
有没有办法从我的 .screenrc 向 GNU Screen 窗口发送一系列命令?看起来这应该很容易做到:
.screenrc:
startup_message off
screen -t "RAILS SERVER"
<send command to last created window> <my alias to cd Rails project>
<send command to last created window> rails s
screen -t "RAILS CONSOLE"
<send command to last created window> <my alias to cd to Rails project>
rails c
我已经多次浏览了 Screen 手册页,但找不到任何可以
。
谢谢, 最大限度
Is there a way to send a sequence of commands to GNU Screen windows from my .screenrc? It seems like this should be easy to do:
.screenrc:
startup_message off
screen -t "RAILS SERVER"
<send command to last created window> <my alias to cd Rails project>
<send command to last created window> rails s
screen -t "RAILS CONSOLE"
<send command to last created window> <my alias to cd to Rails project>
rails c
I've gone over the Screen man-page several times, but can't find anything that will <send command to last created window>
.
Thanks,
Max
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Keith 的答案完成了工作,但它将窗口与该进程绑定在一起,以便应用程序执行完毕后,窗口就会关闭。
这就是我最终所做的,效果非常好:
这里要注意的重要部分是 ^M 字符。这实际上不是一个 ^ 后跟一个 M。这是一个原始的换行符。在几乎所有 CLI 程序(vi、emacs、shell)中,您可以按 CTRL-V,然后按 ENTER 来生成此字符。
这是如何运作的? stuff 命令将给定的字符串直接键入控制台。最后的换行文字实际上按照您自己键入的通常方式发送命令。希望有帮助!我发现这种方法比其他方法远更加稳定和可靠。
Keith's answer gets the job done but it ties the window to that process so that as soon as the application is done executing, the window closes.
Here's what I wound up doing that worked perfectly:
The important part to note here is the ^M character. This isn't actually a ^ followed by an M. This is a raw newline character. In almost any CLI program (vi, emacs, shell), you can press CTRL-V and then press ENTER to generate this character.
How does this work? The stuff command types the given string directly into the console. The newline literal at the end actually sends the command off the way you normally would if you typed it yourself. Hope that helps! I've found this approach to be far more stable and reliable than others.
它不是一个单独的命令;您只需指定要在创建窗口的行上运行的命令。
例如(未经测试):
It's not a separate command; you just specify the command to run on the line that creates the window.
For example (untested):