GNU 屏幕:环境变量
[已更新] 该问题与问题 GNU Screen:程序员在 Readbuf 中引用 和 < a href="https://stackoverflow.com/questions/1318046/gnu-screen-files-to-numbered-buffers">GNU Screen:文件到编号缓冲区?。由于它们尚未解决,因此该问题针对有关环境变量的更一般概念。我相信它们是提高 Screen 效率的关键。
1.我如何在 Screen 中使用 Bash 的变量,例如:
$ export path=`pwd`
$ ^a :readbuf `echo $path`/debugging_code.php
2.我如何重用屏幕的缓冲区,例如:
$ ^a :readreg a `echo $path`
$ ^a :readbuf $a/debugging_code.php
$ ^a ]
3。如何像环境变量一样使用 Screen 的缓冲区?
[Updated]
The question is related to the questions GNU Screen: Programmers quotes in Readbuf and GNU Screen: files to numbered buffers?. Since they are not solved, the question targets more general concept about environment variables. My belief is that they are the key to make Screen more efficient.
1. How can I use Bash's variables in Screen like:
$ export path=`pwd`
$ ^a :readbuf `echo $path`/debugging_code.php
2. How can I reuse Screen's buffers like:
$ ^a :readreg a `echo $path`
$ ^a :readbuf $a/debugging_code.php
$ ^a ]
3. How can I use Screen's buffers like environment variables?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下命令不会创建新的屏幕会话,但会创建屏幕内部变量。在命令行上运行它允许您使用 shell 扩展:
然后使用新变量:
The following command does not create a new screen session, but it will create a screen internal variable. Running it on the command line allow you to use the shell expansion:
Then use the new variable:
我已经为 screen 4.0.3 创建了一个补丁,支持以下语法:
这允许您执行任意 shell 命令并将输出通过管道传输到屏幕缓冲区中。请注意,这是通过使用 popen 执行子 shell 并将标准输出复制到 bufferfile 设置中指定的当前文件(然后读取该文件)来实现的,所以要小心你不会覆盖你不打算覆盖的东西。此外,该补丁可能非常不安全,因此请自行承担使用风险。
一个例子可能是:
任何 shell 命令都按照键入的字面意思执行。
请参阅 Github 上的 gnu-screen-readbuf-exec,了解包含修补。
I have made a patch to screen 4.0.3 that supports the following syntax:
This allows you to exec any arbitrary shell command and pipe the output into the screen buffer. Note that this is implemented by executing a subshell using
popen
and copying the standard output to the current file specified in thebufferfile
setting (and then reading that file), so be careful you don't overwrite something you don't intend to. Also, this patch is probably terribly insecure so please use it at your own risk.An example might be:
Any shell command is executed literally as typed.
See gnu-screen-readbuf-exec on Github for the Git repository containing the patch.