Unable to understand a code in .screenrc

后端 未结 1 1932
独厮守ぢ
独厮守ぢ 2021-01-27 03:38

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

# prev         


        
相关标签:
1条回答
  • 2021-01-27 04:19

    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.
    0 讨论(0)
提交回复
热议问题