无法理解.screenrc中的代码 [英] Unable to understand a code in .screenrc
问题描述
我不确定以下 Rampion的代码的确切目的. 显然,它应该在光标位置执行命令.
I am not sure about the exact purpose of the following Rampion's code. It should apparently execute command(s) at the cursor position.
# man-word.screen
# prevent messages from slowing this down
msgminwait 0
# copy word starting at cursor
copy # I am not sure why we need this
stuff " e "
# open a new window that waits for a word to run man on
# (and uses 'read' to pause on error)
screen -t man /bin/sh -c 'cat | xargs man || read' # option -c seems to mean execute
# feed that window the copied word
# be sure to enter '^M' as 'CTRL-V ENTER' and '^D' as 'CTRL-V CTRL-D' (in vim)
paste '.'
# should display as 'stuff "^M^D"'
stuff " "
# turn message waiting back on
msgminwait 1
# vi: ft=screen
代码绑定在^g
下,这样
bindkey -m ^f source /Users/masi/bin/screen/edit-file-under-cursor.screen
与
bind f source /Users/masi/bin/screen/edit-file-under-cursor.screen
我运行的代码是因为我的光标位于下一行的开头
I run the code as my cursor is at the beginning of the following line
vim ~/.zshrc
我得到了一个这样的新缓冲区
I get a new buffer such that
替代文字http://files.getdropbox.com/u/175564 /screen-rampion.png
命令的作用是什么?
推荐答案
因此,该命令不会运行任意代码.如果您的光标位于单词<whatever>
上,则所有操作均在新屏幕窗口中运行man <whatever>
.
So the command doesn't run arbitrary code. All it does is run man <whatever>
in a new screen window if your cursor was over the word <whatever>
.
使用copy
命令的原因是,您需要告诉屏幕您要复制的内容.在路径上时,您可能并不总是处于屏幕的复制模式下-例如,您可能正在使用vim,并且使vim的光标位于路径上.如果您已经处于复印模式,则为空操作.
The reason the copy
command is there is that you need to tell screen that you want to copy something. You may not always be in screen's copy mode when over a path - for example, you could be using vim, and have vim's cursor over a path. If you are already in copy mode, then it's a no-op.
screen -t man /bin/sh -c 'cat | xargs man || read'
-
screen
::打开新窗口 -
-t man
::命名为man
-
/bin/sh -c 'cat | xargs man || read'
::在新窗口中运行此命令,而不是在新窗口中打开默认Shell.-
/bin/sh
::一个shell程序 -
-c 'cat | xargs man || read'
::将给定的字符串作为脚本运行,而不是以交互方式打开 -
cat |
::等待用户输入(以换行符和CTRL-D结尾),然后将其作为用户输入传递给下一条命令 -
xargs man
::调用man
,使用从标准输入中读取的内容作为man
的命令行参数
-
|| read
::如果先前的命令返回的非零值,请等待用户按下Enter键 screen
:: open a new window-t man
:: give it a title ofman
/bin/sh -c 'cat | xargs man || read'
:: run this command in the new window, rather than opening the default shell in the new window./bin/sh
:: a shell program-c 'cat | xargs man || read'
:: run the given string as a script, rather than opening in interactive modecat |
:: wait for user input (ended with a newline and a CTRL-D), then pipe it as user input to the next commandxargs man
:: callman
, using whatever's read from standard input as command line arguments forman
|| read
:: if the previous commands return non-zero, wait for the user to hit enter- 该命令的
-c
部分无法运行,因为它看起来像一个新的外壳($
是一个提示). -
stuff "^M^D"
部分未正确转录.应当输入paste '.'
之后的下一个非注释行,即击键,例如: - The
-c
part of the command isn't getting run, since it looks like a new shell (the$
is a hint). The
stuff "^M^D"
part wasn't transcribed correctly. The next non-comment line afterpaste '.'
should be entered, keystroke for keystroke, as :
从您的输出看起来像
's', 't', 'u', 'f', 'f', ' ', '"', <CTRL-V>, <ENTER>, <CTRL-V>, <CTRL-D>, '"'
-
bindkey -m ^f
将命令绑定到<CTRL-f>
,但仅当处于复制模式时. -
bind f
在所有模式下都将命令绑定到<CTRL-A> f
. bindkey -m ^f
binds a command to<CTRL-f>
, but only when in copy mode.bind f
binds a command to<CTRL-A> f
, in all modes.
如果您下载了文件,而不是转录了该文件,则可能不会有那些问题.
If you had downloaded the file, rather than transcribed it, you may not have those issues.
此外,
bindkey -m ^f
与bind f
不同.而且都没有将命令绑定到^g
.Also,
bindkey -m ^f
is not the same asbind f
. And neither bind a command to^g
.这篇关于无法理解.screenrc中的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
-