Problem: to have a keyboard shortcut to google a current selection in Screen's copy mode from terminal to Firefox
问题:有一个键盘快捷键,可以将屏幕复制模式中的当前选择从终端谷歌到Firefox
You can copy the sentence to Screen's clipboard in copy-mode by pressing enter
. However, I want to be able to press g
to put the Screen's clipboard to the command below as the first parameter:
您可以按Enter键将句子复制到复制模式的屏幕剪贴板中。但是,我希望能够按g将Screen的剪贴板放到下面的命令中作为第一个参数:
#!/bin/sh
q=$1
open "http://www.google.com/search?q=$q"
I do the same at the moment by
我现在也这样做
- C-a Esc [select the area] enter
- C-z [to put the current window out of the way]
- google C-a ]
C-a Esc [选择区域]输入
C-z [将当前窗口排除在外]
谷歌C-a]
How can you put Screen's clipboard to the command?
如何将Screen的剪贴板放入命令?
3 个解决方案
#1
Here's a description of how someone modified their .screenrc file to sync it with the X clipboard. You might try modifying it to send the selected text to Firefox instead of xsel.
以下是有人如何修改.screenrc文件以将其与X剪贴板同步的说明。您可以尝试修改它以将所选文本发送到Firefox而不是xsel。
#2
open "http://www.google.com/search?q=`xclip -o`"
This works on X's copy buffer rather than Screen's but the X clipboard is usually what you want since it is set by simply highlighting text.
这适用于X的复制缓冲区而不是屏幕,但X剪贴板通常是你想要的,因为它只是通过突出显示文本来设置。
#3
I'm still trying to work out the exact syntax but take a look at using 'bind' with 'writebuf' (and possibly 'eval') within your .screenrc file.
我仍然试图找出确切的语法,但是看一下在.screenrc文件中使用'bind'和'writebuf'(可能还有'eval')。
EDIT
You can bind keys in the .screenrc file in your home directory. E.g.,
您可以绑定主目录中.screenrc文件中的键。例如。,
bind g eval 'writebuf' 'exec . /bin/sh/ -c "cp /tmp/screen-exchange ~/foo.txt"'
This runs the eval command when you use the g key in screen. Eval takes any number of arguments and runs them as a Tcl script.
当您在屏幕中使用g键时,它会运行eval命令。 Eval接受任意数量的参数并将它们作为Tcl脚本运行。
writebuf dumps your screen copy/paste buffer into a file at /tmp/screen-exchange.
writebuf将您的屏幕复制/粘贴缓冲区转储到/ tmp / screen-exchange的文件中。
The second string starts with exec which will run a program external to the Tcl interpreter. In this case, I choose /bin/sh (a *nix shell) and pass an arbitrary system command. The example above copies the /tmp/screen-exchange file but you might:
第二个字符串以exec开头,它将运行Tcl解释器外部的程序。在这种情况下,我选择/ bin / sh(a * nix shell)并传递任意系统命令。上面的示例复制/ tmp / screen-exchange文件,但您可能:
open < /tmp/screen-exchange
Once the line has been added to ~/.screenrc, restart screen, copy some text and try
将行添加到〜/ .screenrc后,重新启动屏幕,复制一些文本并尝试
C-a g
#1
Here's a description of how someone modified their .screenrc file to sync it with the X clipboard. You might try modifying it to send the selected text to Firefox instead of xsel.
以下是有人如何修改.screenrc文件以将其与X剪贴板同步的说明。您可以尝试修改它以将所选文本发送到Firefox而不是xsel。
#2
open "http://www.google.com/search?q=`xclip -o`"
This works on X's copy buffer rather than Screen's but the X clipboard is usually what you want since it is set by simply highlighting text.
这适用于X的复制缓冲区而不是屏幕,但X剪贴板通常是你想要的,因为它只是通过突出显示文本来设置。
#3
I'm still trying to work out the exact syntax but take a look at using 'bind' with 'writebuf' (and possibly 'eval') within your .screenrc file.
我仍然试图找出确切的语法,但是看一下在.screenrc文件中使用'bind'和'writebuf'(可能还有'eval')。
EDIT
You can bind keys in the .screenrc file in your home directory. E.g.,
您可以绑定主目录中.screenrc文件中的键。例如。,
bind g eval 'writebuf' 'exec . /bin/sh/ -c "cp /tmp/screen-exchange ~/foo.txt"'
This runs the eval command when you use the g key in screen. Eval takes any number of arguments and runs them as a Tcl script.
当您在屏幕中使用g键时,它会运行eval命令。 Eval接受任意数量的参数并将它们作为Tcl脚本运行。
writebuf dumps your screen copy/paste buffer into a file at /tmp/screen-exchange.
writebuf将您的屏幕复制/粘贴缓冲区转储到/ tmp / screen-exchange的文件中。
The second string starts with exec which will run a program external to the Tcl interpreter. In this case, I choose /bin/sh (a *nix shell) and pass an arbitrary system command. The example above copies the /tmp/screen-exchange file but you might:
第二个字符串以exec开头,它将运行Tcl解释器外部的程序。在这种情况下,我选择/ bin / sh(a * nix shell)并传递任意系统命令。上面的示例复制/ tmp / screen-exchange文件,但您可能:
open < /tmp/screen-exchange
Once the line has been added to ~/.screenrc, restart screen, copy some text and try
将行添加到〜/ .screenrc后,重新启动屏幕,复制一些文本并尝试
C-a g