GNU 屏幕:环境变量

发布于 2024-08-02 10:27:19 字数 697 浏览 2 评论 0原文

[已更新] 该问题与问题 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橘亓 2024-08-09 10:27:19

以下命令不会创建新的屏幕会话,但会创建屏幕内部变量。在命令行上运行它允许您使用 shell 扩展:

$ screen -X setenv a "$PWD/debugging_code.php"

然后使用新变量:

C-a :readbuf $a

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:

$ screen -X setenv a "$PWD/debugging_code.php"

Then use the new variable:

C-a :readbuf $a
丑丑阿 2024-08-09 10:27:19

我已经为 screen 4.0.3 创建了一个补丁,支持以下语法:

^A :readbuf !shell-command

这允许您执行任意 shell 命令并将输出通过管道传输到屏幕缓冲区中。请注意,这是通过使用 popen 执行子 shell 并将标准输出复制到 bufferfile 设置中指定的当前文件(然后读取该文件)来实现的,所以要小心你不会覆盖你不打算覆盖的东西。此外,该补丁可能非常不安全,因此请自行承担使用风险。

一个例子可能是:

^A :readbuf !cat $HOME/projects/foobar/file.txt

任何 shell 命令都按照键入的字面意思执行。

请参阅 Github 上的 gnu-screen-readbuf-exec,了解包含修补。

I have made a patch to screen 4.0.3 that supports the following syntax:

^A :readbuf !shell-command

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 the bufferfile 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:

^A :readbuf !cat $HOME/projects/foobar/file.txt

Any shell command is executed literally as typed.

See gnu-screen-readbuf-exec on Github for the Git repository containing the patch.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文