在 Screen 的命令模式下运行 Sed 到 Screen 的剪贴板

发布于 2024-07-27 19:53:55 字数 468 浏览 5 评论 0原文

我在 Screen 的剪贴板中有一个副本,其中包含单词 Masi aften。 我想用 Bond 有效地替换它,以便我直接在 Screen 的命令模式下编辑剪贴板。 我知道我可以将剪贴板保存到 /tmp 并在 Vim 中运行替换,但我想学习 Screen。

我运行时,我的数据在 Screen 的剪贴板中,

Ctrl-A : sed s/Masi/Bond/ | [Screen's clipboard]       /// I do not know how to refer to Screen's clipboard by a command other that C-A ]

我得到

unknown command sed

如何您在屏幕的命令模式下对屏幕的剪贴板运行命令吗?

I have a copy in Screen's clipboard which contains the word Masi aften.
I would like to replace it with Bond effectively such that I edit the clipboard directly in Screen's command-mode. I know that I could save the clipboard to /tmp and run the replacement there in Vim, but I want to learn Screen.

I run as I have my data in Screen's clipboard

Ctrl-A : sed s/Masi/Bond/ | [Screen's clipboard]       /// I do not know how to refer to Screen's clipboard by a command other that C-A ]

I get

unknown command sed

How can you run a command to Screen's clipboard in Screen's command mode?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

反差帅 2024-08-03 19:53:55

我认为屏幕没有任何方式在粘贴缓冲区上运行命令。

一种方法是进行绑定以保存粘贴缓冲区,并在屏幕中打开一个新窗口,运行脚本来修改缓冲区。 然后进行另一个绑定以从磁盘重新加载修改后的缓冲区并粘贴(这可以通过正常的粘贴绑定进行绑定)。

将其添加到 screenrc (更改路径):

bind -c screensed s eval "writebuf /pathtoscript/screensed.clipboard" "screen sh /pathtoscript/screensed.sh"
bind -c screensed p eval "readbuf /pathtoscript/screensed.clipboard" "paste ."
bind , command -c screensed

在某处创建一个 shell 脚本:

#!/usr/bin/env sh
echo "Enter sed script: "
read sedcommand
sed -i ${sedcommand} /pathtoscript/screensed.clipboard
echo "(Enter to return)"
read something

screen 中的“ctrl-a , s”将转储剪贴板并创建一个新窗口以供输入 sed 命令。 “ctrl-a,p”将读取剪贴板并粘贴。 脚本末尾的暂停是为了显示 sed 可能给出的任何错误。

I don't think screen has any way of running commands on the paste buffer.

One way to do it is to make a bind to save the paste buffer and open a new window in screen that runs a script to modify the buffer. Then make another bind to reload the modified buffer from disk and paste (this can be bound over the normal paste bind).

Add this to screenrc (changing paths):

bind -c screensed s eval "writebuf /pathtoscript/screensed.clipboard" "screen sh /pathtoscript/screensed.sh"
bind -c screensed p eval "readbuf /pathtoscript/screensed.clipboard" "paste ."
bind , command -c screensed

Make a shell script somewhere:

#!/usr/bin/env sh
echo "Enter sed script: "
read sedcommand
sed -i ${sedcommand} /pathtoscript/screensed.clipboard
echo "(Enter to return)"
read something

"ctrl-a , s" in screen will dump the clipboard and make a new window for the sed command to be entered. "ctrl-a , p" will read the clipboard and paste. The pause at the end of the script is to show any errors sed might give.

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