Vim's variant. Vim should be the default editor.
- Pick long command from history, using up/down arrows.
I have chosen this:
echo one two three > new_file.txt - Press
Ctrl + xCtrl + ecombination. It will open our long command inside Vim. PressCtrl + g, for showing the temporary file name in the bottom of the vim window. In my case it is/tmp/bash-fc.230BC2 - Go to another tty, type
vim /tmp/bash-fc.230BC2(using filename autocomplete, of course). It will tell you "Swap file already exist" - pressO, for open read only. - Then, inside vim, you are needed the next key sequence:
yy : ! Ctrl+r " Enter
Explanation:
yy- copy all line:- go to the command-line mode!- execute command with shellCtrl+r "- paste the copied line to the command line.Enter- execute command
I should mention, that all this key sequence can be mapped to one keystroke, by .vimrc file edit.
It is done - command was copied from one tty to another and executed.