2

[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?

4

2 回答 2

4

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
于 2009-08-23T10:35:42.163 回答
1

我对屏幕 4.0.3 做了一个补丁,它支持以下语法:

^A :readbuf !shell 命令

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

一个例子可能是:

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

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

有关包含补丁的 Git 存储库,请参阅Github上的 gnu-screen-readbuf-exec

于 2009-08-23T11:07:50.833 回答