Is there a way to copy all the text from the integrated Visual Studio Code terminal? I have some output that I want to copy to a text file and save it.
Is there a way to copy all the text from the integrated Visual Studio Code terminal? I have some output that I want to copy to a text file and save it.
I can just right-click in the terminal and chose Select All and then right-click and Copy. Does that not work for you?
There is an unbound command for the selection:
workbench.action.terminal.selectAll
and Ctrl+C for the copy.
If you do this a lot you could make a macro to do the whole thing: select, copy, open a new text file and paste.
Use the Terminal Capture extension to open your terminal output and open it in a tab. You can then modify and save it in any way you want.
I moved from linux to windows and I realized many things are different. Before I could simply right click > select all > copy. On windows aparently the default behavior is to paste. So I changed my settings like this:
"terminal.integrated.rightClickBehavior": "default"
Another option, with VSCode 1.70 (July 2022)
PR 153235 (solving issue 152097)
Add command to copy output of the last command
The awesome shell integration makes it really easy to rerun commands and copy the output from those commands.
However, it seems one can only copy the output if the line the command was executed from is still within the scroll limit of the terminal.
For some very long runs this is inconvenient.It would be really nice to be able to:
- Copy output of last command from a terminal
- Copy output of any command in the history of that terminal, if it is available to be copied
Both without having to scroll to the point the command was executed.
You now have the CopyLastCommand command (workbench.action.terminal.copyLastCommand).
Available today in VSCode insiders.
VsCode 1.72 (Sept. 2022) will improve the selection of the last commands (using Ctrl+Shift+Up / Cmd+Shift+Up), for taking into acount empty commands in the terminal:
Currently Ctrl/Cmd+Arrow and Ctrl/Cmd+Shift+Arrow treats "empty commands" (the circle outlines) like every other command.
This would feel much nicer if they were completely skipped such that Ctrl+Shift+Up would select the output of the previous non-empty command.
Solution: PR 155551
This PR implements the skipping of empty commands in the case of the terminal with non-partial command detection capabilities.
The result is:
I couldn't right click in the terminal, but there's a quick open command (ctrl+p) called Terminal: Select All