Copy Paste in Bash on Ubuntu on Windows

208,924

Solution 1

Update 2019/04/16: It seems copy/paste is now officially supported in Windows build >= 17643. Take a look at Rich Turner's answer. This can be enabled through the same settings menu described below by clicking the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste".


Another solution would be to enable "QuickEdit Mode" and then you can paste by right-clicking in the terminal.

To enable QuickEdit Mode, right-click on the toolbar (or simply click on the icon in the upper left corner), select Properties, and in the Options tab, click the checkbox next to QuickEdit Mode.

With this mode enabled, you can also copy text in the terminal by clicking and dragging. Once a selection is made, you can press Enter or right-click to copy.

Solution 2

To get right-click to paste to work:

  • Right-click on the title bar > Properties
  • Options tab > Edit options > enable QuickEdit Mode

enter image description here

Solution 3

Ok, it's developed finally and now you are able to use Ctrl+Shift+C/V to Copy/Paste as of Windows 10 Insider build #17643.

You'll need to enable the "Use Ctrl+Shift+C/V as Copy/Paste" option in the Console "Options" properties page:

enter image description here
(source: windows.net)

referenced in blogs.msdn.microsoft.com/

Solution 4

At long last, we're excited to announce that we FINALLY implemented copy and paste support for Linux/WSL instances in Windows Console via CTRL + SHIFT + [C|V]!

You can enable/disable this feature in case you find a keyboard collision with a command-line app, but this should start working when you install and run any Win10 builds >= 17643. Select "Properties" from the menu to access the following dialog box.

New Console Properties showing CTRL + SHIFT + C/V option

Thanks for your patience while we re-engineered Console's internals to allow this feature to work :)

Solution 5

You can use AutoHotkey (third party application), the command below is good with plain alphanumeric text, however some other characters like =^"%#! are mistyped in console like bash or cmd. (In any non-console window this command works fine with all characters.)

^+v::SendRaw %clipboard%
Share:
208,924

Related videos on Youtube

Ghassan Zein
Author by

Ghassan Zein

I'm a senior system administrator who is always focusing on Open Source Technologies.

Updated on March 20, 2022

Comments

  • Ghassan Zein
    Ghassan Zein about 2 years

    How to execute a copy paste operation from Windows 10 to the Bash on Ubuntu on Windows environment?

    I tried the following:

    • ctrl + shift + v
    • right click to paste

    Any suggestions?

    • Ghassan Zein
      Ghassan Zein over 7 years
      I updated the question so you can understand it.. it's about the NEW ubuntu bash on windows.
    • glenn jackman
      glenn jackman over 7 years
      What is your terminal?
    • Ghassan Zein
      Ghassan Zein over 7 years
      Guys you are missing something: Windows Anniversary 10 Update has a new ubuntu bash integrated with it, so please read about it and then you'll understand the question. My terminal IS UBUNTU BASH ON WINDOWS!
    • user
      user almost 7 years
      See also the issue: Keyboard shortcuts for copy / paste into console on the Microsoft/BashOnWindows repository.
    • Kenny Evitt
      Kenny Evitt almost 7 years
      This should be re-opened. From the Bash on Ubuntu on Windows 'about' page [emphasis mine]: "Bash on Windows provides developers with a familiar Bash shell and Linux environment ...".
    • Kenny Evitt
      Kenny Evitt almost 7 years
      As-of the Windows "Creators Update" you should be able to copy to the clipboard by piping to clip.exe, e.g. echo "Blah blah blah" | clip.exe.
    • Evan Rosica
      Evan Rosica over 6 years
      After experimenting, ctrl+shift+c to copy and ctrl+shift+p to paste works for me. I'd post this as an answer but the question is closed.
    • Peter Mortensen
      Peter Mortensen almost 6 years
      What happened when you tried it? E.g. was there an error message?
  • Ghassan Zein
    Ghassan Zein over 7 years
    This is temporary a good solution, but weird how do they release it without the simplest features..
  • RSmithlal
    RSmithlal almost 7 years
    I didn't realise that right-clicking did the paste right away... I was expecting to see a context menu pop up with options.
  • Felipe Alvarez
    Felipe Alvarez almost 7 years
    DISPLAY has absolutely nothing to do with vim or copy and pasting.
  • Felipe Alvarez
    Felipe Alvarez almost 7 years
    After using left mouse button to select text, I have to right click twice to get the text to paste.
  • Jon49
    Jon49 almost 7 years
    @FelipeAlvarez Apparently it worked for me. Let me know if you come up with a better solution!
  • user
    user almost 7 years
    I tried using ^#v as Ctrl+Shift+V, but it did not work because ^#v stands for Ctrl+WinKey+V. You should use ^+v, which stands for Ctrl+Shift+V.
  • alpha_989
    alpha_989 almost 7 years
    Yes.. mouse click works.. is there a way to do this with keyboard only (selection and paste)? that is the point of using VIM/UBUNTU/Shell after all.
  • alpha_989
    alpha_989 almost 7 years
    Can you clarify what is the insert mode?
  • alpha_989
    alpha_989 almost 7 years
    @Jon49, Can you explain what this is doing? Are you putting this in .vimrc? or within vim like :export DISPLAY=localhost:0.0
  • jaredlt
    jaredlt almost 7 years
    @alpha_989 Insert Mode inserts text at the cursor (and pushes subsequent characters to the right), rather than overwrite characters to the right of the cursor. Insert Mode is the default mode most people expect. From testing it doesn't seem like this setting is respected in WSL. I have it unchecked but it still inserts rather than overwrites.
  • Jon49
    Jon49 almost 7 years
    @alpha_989, That goes into the Ubuntu terminal. I believe it connects Ubuntu and Windows somehow. Been a while so I don't remember all the details.
  • qwertzguy
    qwertzguy over 6 years
    So no way to paste with the keyboard?
  • chipit24
    chipit24 over 6 years
    @FelipeAlvarez You only have to right click once to paste. The first time you right click you are copying the text; please read the answer more carefully. It's been a while since I used Bash on Ubuntu on Windows, but did not find a way to enable copy/paste with the keyboard.
  • Erin Drummond
    Erin Drummond over 6 years
    Although it requires a third party program, that seems to be normal to make Windows usable anyway. I think this is the best answer because it allows you to retain the keyboard shortcut you're used to
  • Paul Vixie
    Paul Vixie over 6 years
    until when exactly? it's january 2018 and they did not fix the control key shortcuts yet. this is in creators update.
  • chx
    chx over 6 years
    I am using +Ins because ^+v collides with any program already using that for other purposes in some contexts like nano "jump to last line". I have yet to find anything using shift+insert for different purposes.
  • mltsy
    mltsy about 6 years
    Warning: This will cause programs to hang while scrolling text on the screen if you click on them, until you press enter to continue. See stackoverflow.com/questions/30418886/…
  • Jacob Goulden
    Jacob Goulden almost 6 years
    How do I check my current build version and force an update if I do not see this
  • Rich Turner
    Rich Turner almost 6 years
    To find your current Windows version, run winver from the run dialog or command-line. To get early access to these and other features as they're being built, you'll need to sign up for the Windows Insider Program; details here: insider.windows.com/en-us
  • Ian Clark
    Ian Clark almost 6 years
    @RichTurner thanks for this - I knew the feature existed but found it really hard to see the minimum version number attached to it. Looks like I'll need to upgrade to get access :)
  • Rich Turner
    Rich Turner almost 6 years
    Blog post starts with "As of Windows 10 Insider build #17643" ;)
  • Jeremy Bernier
    Jeremy Bernier almost 6 years
    And for those who want it to paste instantly rather than one character at a time: ^+v::SendInput %clipboard%
  • methodsignature
    methodsignature almost 6 years
    2018 here, don't see this in production (full windows 10 with ubuntu from the app store). sigh.
  • Todd Freed
    Todd Freed almost 6 years
    How do you know what Windows build you're on? I don't see this option.
  • αғsнιη
    αғsнιη almost 6 years
    type in Run/Start, winver @methodsignature
  • Hippyjim
    Hippyjim almost 6 years
    Nope. Does nothing.
  • Craig Silver
    Craig Silver over 5 years
    Although this solution is a pretty heavy-handed one for a feature that really should be integrated into Windows Bash (and will be soon with build 17643?), it gave me Shift+Ins for paste without even messing with the settings. Plus, I am excited to check out the app for what else it offers.
  • Stuart Brock
    Stuart Brock over 5 years
    Thanks for the comment. From what I can tell Shf+Ins is not going to be available in build 17643 - Just Shf+Ctrl+V. I use Shf+Ins every day so didn't want to learn an alternative key press.
  • Nafeez Abrar
    Nafeez Abrar over 5 years
    Could not find this option in the latest Ubuntu App of Windows 10 1803.
  • Rich Turner
    Rich Turner over 5 years
    As per the blog post above, this first shipped in Win10 Insider build 17643, and will be included in the Fall 2018 Update shipping "soon"™ ;)
  • Rich Turner
    Rich Turner over 5 years
    @NafeezAbrar - Blog post starts with "As of Windows 10 Insider build #17643" - 1803 was build 17682. This feature will ship in builds >= 17643, leading up to general release in Windows 10 Fall 2018 Update.
  • Steve Goossens
    Steve Goossens over 5 years
    What you describe as broken sounds like you don't have Quick Edit mode enabled in the console settings
  • Nafeez Abrar
    Nafeez Abrar over 5 years
    @methodsignature Found this feature in Windows 10 (1809). Try to update your windows now.
  • Nafeez Abrar
    Nafeez Abrar over 5 years
    @RichTurner I have updated to 1809 today. It works fine.
  • Rich Turner
    Rich Turner over 5 years
    @Nafeez Abrar: Good to hear. Thanks for letting us know :)
  • Doctor Coder
    Doctor Coder about 5 years
    Works strange, replaces / chart to | so paths /a/b/c turns into |a|b|c
  • MarkHu
    MarkHu about 5 years
    Apparently, newer builds of Windows 10 became available to the general public later in 2018, or early 2019. But the update didn't happen automatically. Go into Settings, Windows Update, and click on Check for Updates.
  • low351
    low351 almost 5 years
    Thanks for this, I've been missing my shf+Ins since I dumped cygwin in favor of WSL. And I really like this application for mor than just that.
  • BND
    BND over 4 years
    A similar way to copy?
  • BND
    BND over 4 years
    How to make this the default setting, I notice I have to do that every time I open a new terminal.
  • αғsнιη
    αғsнιη over 4 years
    Hi @BND currently I'm not a Windows user and don't know why it's not keeping the changes; maybe you can run it 'as administrator' and do change and see if it's can keep or you will need to modify in registery regedit (but again dono the registry key); opening a question would be your another choice as well
  • Matthew
    Matthew about 4 years
    For Auto Hot Key users (like me) this is great, thanks! I didn't like how slow it pasted, and @JeremyBernier's suggestion for SendInput is better, but still a little slower than a real Shif+Insert. So I made an AHK script that only does SendInput %clipboard% for ubuntu.exe, and for everything else does SendInput {shift down}{insert}{shift up} to keep other apps pasting at normal speed: gist.github.com/myerspliers/89bc7f9257b659ac239e2911ebad5e9e
  • liltitus27
    liltitus27 over 3 years
    mintty is a much more lightweight option that allows for shift/ctrl+insert copying and pasting
  • Nagev
    Nagev about 3 years
    I installed Ubuntu bash on a recent Windows build (19042 > 17643) and I had to manually tick the box. The copy paste shortcut is still not the default.
  • Rich Turner
    Rich Turner about 3 years
    Making this option the default would break too many apps which use CTRL + SHIFT + C/V for other purposes. Also, we STRONGLY encourage you to use Windows Terminal rather than the legacy Console.
  • Nagev
    Nagev almost 3 years
    Thanks, just installed Windows Terminal and it looks good, but it's a PowerShell rather than a Linux environment; for example uname returns an error. Which is why I use the Ubuntu Terminal mentioned in this post, don't know if that is what you're calling a "legacy console". There's a "Use legacy console" checkbox but I always leave that unticked (the default).
  • Nagev
    Nagev almost 3 years
    Ah, you can select Ubuntu on Windows Terminal. Totally missed that, should be an answer!