How do I copy results from the commandline directly to the clipboard?
On Windows's cmd.exe I can do simply echo "asd" | clip
and it pipes output to the clipboard.
I tried to install xclip
for that, and though it compiled, when called it prints:
Error: Can't open display: (null)
Using mouse is not the solution.
Copying and Pasting in Git Bash There are two ways to copy and paste in Git Bash: Keyboard: Hold Shift and use the left/right arrows to select a text area, then press Enter to copy. Paste text by pressing Insert . Mouse: Left-click and drag to highlight a text selecting, then right click to copy.
You can now press Ctrl+Shift+C to copy selected text in the Bash shell, and Ctrl+Shift+V to paste from your clipboard into the shell. Because this feature uses the standard operating system clipboard, you can copy and paste to and from other Windows desktop applications.
Copy a File ( cp ) You can also copy a specific file to a new directory using the command cp followed by the name of the file you want to copy and the name of the directory to where you want to copy the file (e.g. cp filename directory-name ). For example, you can copy grades. txt from the home directory to documents .
Similarly, you can use Ctrl+shift+C to copy text from the terminal and then use it to paste in a text editor or web browser using the regular Ctrl+V shortcut. Basically, when you are interacting with the Linux terminal, you use the Ctrl+Shift+C/V for copy-pasting.
In Build 14393 or later, if you want to copy something to clipboard in WSL console, just add '.exe' to what you do in Windows cmd.
echo "aaa"|clip.exe
To read from clipboard:
powershell.exe -command "Get-Clipboard"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With