I often have multiple integrated (bash / zsh) terminals open in VS Code. Sometimes I enter a command in the wrong terminal (e.g. git commit ...
in a terminal without pre-commit hooks in the environment).
Currently, I then press up to show the most recent command, manually select the input using the mouse, copy to clipboard, switch terminals, where I paste and re-run the command.
It'd be great to perform these steps without relying on the mouse. Hence, I am wondering whether there is a shortcut / keyboard binding to copy the input of the current integrated terminal to the system clipboard?
I often have multiple integrated (bash / zsh) terminals open in VS Code. Sometimes I enter a command in the wrong terminal (e.g. git commit ...
in a terminal without pre-commit hooks in the environment).
Currently, I then press up to show the most recent command, manually select the input using the mouse, copy to clipboard, switch terminals, where I paste and re-run the command.
It'd be great to perform these steps without relying on the mouse. Hence, I am wondering whether there is a shortcut / keyboard binding to copy the input of the current integrated terminal to the system clipboard?
When you are in bash/VSCode/MacOS, you can define a key binding with :
bind "\"$(tput kf4)\":\"'|pbcopy\x01 echo '\n\""
then you can recall a command, type F4, the command text will be copied into clipboard.
This needs to be tuned if your command contains single quotes.
Terminal: Copy Last Command
command - but it doesn't do anything for me in Git Bash on Windows. – Mark Commented Jan 30 at 23:13