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 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
From your output it looks like
- 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>, '"'
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.