Unable to understand a code in .screenrc

偶尔善良 提交于 2019-12-02 06:22:52

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>.

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 :: open a new window
  • -t man :: give it a title of man
  • /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 mode
    • cat | :: wait for user input (ended with a newline and a CTRL-D), then pipe it as user input to the next command
    • xargs man :: call man, using whatever's read from standard input as command line arguments for man
    • || read :: if the previous commands return non-zero, wait for the user to hit enter

From your output it looks like

  1. The -c part of the command isn't getting run, since it looks like a new shell (the $ is a hint).
  2. The stuff "^M^D" part wasn't transcribed correctly. The next non-comment line after paste '.' should be entered, keystroke for keystroke, as :

    's', 't', 'u', 'f', 'f', ' ', '"', <CTRL-V>, <ENTER>, <CTRL-V>, <CTRL-D>, '"'
    

If you had downloaded the file, rather than transcribed it, you may not have those issues.

Also, bindkey -m ^f is not the same as bind f. And neither bind a command to ^g.

  • 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.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!