Copy Paste in Bash on Ubuntu on Windows - bash

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?

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.

To get right-click to paste to work:
Right-click on the title bar > Properties
Options tab > Edit options > enable QuickEdit Mode

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.
Thanks for your patience while we re-engineered Console's internals to allow this feature to work :)

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%

Right-click the title bar, select context menu Edit -> Paste (until they fix the control key shortcuts)

As others have said, there is now an option for Ctrl+Shf+Vfor paste in Windows 10 Insider build #17643.
Unfortunately this isn't in my muscle memory and as a user of TTY terminals I'd like to use Shf+Ins as I do on all the Linux boxes I connect to.
This is possible on Windows 10 if you install ConEmu which wraps the terminal in a new GUI and allows Shf+Ins for paste. It also allows you to tweak the behaviour in the Properties.
The Console looks like this:
Copy options:
Paste options:
Shf+Ins works out of the box. I can't remember if you need to configure bash as one of the shells it uses but if you do, here is the task properties to add it:
Also allows tabbed Consoles (including different types, cmd.exe, powershell etc). I've been using this since early Windows 7 and in those days it made the command line on Windows usable!

Like it has been written before:
Right Click on Bash on Ubuntu on Windows Icon if you have it on a Task Bar Shortcut Icon
Click on Properties
Select Options Tab on the Properties Window
Check the QuickEditMode option
Click Apply
Now you are able to open a new Bash Terminal and just use Right-Click to paste
In order to be able to copy from Terminal, Just use CTRL+M and this will enable you to select and copy selected Text.

For pasting into Vim in the terminal (bash on ubuntu on windows):
export DISPLAY=localhost:0.0
Not sure how to copy from Vim though :-(

Alternate solution over here, my windows home version Windows Subsystem Linux terminal doesn't have the property to use Shift+Ctrl (C|V)
Use an actual linux terminal]1
Install an X-server in Windows (like X-Ming)
sudo apt install <your_favorite_terminal>
export DISPLAY=:0
fire your terminal app, I tested with xfce4-terminal and gnome-terminal
windows #ubuntu #development

For just copying (possibly long) texts to the Windows clipboard, I have found that just piping the output to clip.exe (including the .exe file extension) works fine for me. So:
$ echo "Hello World" | clip.exe
lets me paste Hello World using Ctrl-V anywhere else.
Now that I have posted this, I notice that related question Pipe from clipboard in linux subsytem for windows includes this and a command solution for pasting from the Windows clipboard as well.

you might have bash but it is still a windows window manager. Highlite some text in the bash terminal window. Right click on the title bar, select "Edit", select "Copy", Now Right Click again on the Title bar, select "Edit" , Select "Paste", Done. You should be able to Highlite text, hit "Enter" then Control V but this seems to be broken

For autohotkey users, a full answer is:
#IfWinActive ahk_class ConsoleWindowClass
^+v::SendInput %clipboard%
Which checks that you're in a console (windows or ubuntu) before pasting from the windows clipboard.

That turned out to be pretty simple. I've got it occasionally. To paste a text you simply need to right mouse button click anywhere in terminal window.

Related

How to get that terminal button on right click?

How to get the terminal button on right click on widows?
The btn looks like this
Terminal Btn
On click of that btn, it opens the terminal.
Termianl
Windows Terminal Preview v1.1.1671.0 and later installers put the Windows Terminal in the context menu.
https://github.com/microsoft/terminal/releases/tag/v1.1.1671.0
But if you have an older version, you need to update the Windows Registry.
Create a wterminal.reg text file and put the following code in it and then run it. Also, make sure paths to wt.exe and wt_32.ico files are correct on your system. You can change those paths according to your system.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
#="Windows terminal here"
"Icon"="%USERPROFILE%\\AppData\\Local\\terminal\\wt_32.ico"
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
#="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe"
Warning: Be careful and make sure you have a backup of the Windows Registry before applying any changes.
Here you can find more information about it: https://github.com/microsoft/terminal/issues/1060#issuecomment-497539461

Can I have multiple Powershell Consoles in one window?

So, now I have many open apps, often 3-4 powershell consoles. I'm able to order the powershell windows to watch them together (top left, top right, bottom left, bottom right).
So this means that if I switch to another app, when I switch back I have to restore all multiple powershell windows to see them all again.
What I want is, to create only one 'shared window' for many powershell, because when I need one, I need all of them to see.
Is there a way to do this?
Just to add more details about Windows Terminal approach:
Open a Windows Terminal
Type Alt+Shift+= or Alt+Shift+- to open a new Pane in the same tab
Type Shift+Ctrl+W to close the current Pane
If you need more details or modify the settings, go to next page Panes in Windows Terminal
ConEmu has this option.
You can also configure it to open as much consoles as you want when it starts.
ConEmu website
Enjoy!
VSCode can have Multiple Terminals which is the closest to this I've seen, quoted from documentaion:
You can create multiple terminals open to different locations and easily navigate between them. Terminal instances can be added by hitting the plus icon on the top-right of the TERMINAL panel or by triggering the Ctrl+Shift+` command. This creates another entry in the dropdown list that can be used to switch between them.
You can also split the terminal by triggering the Ctrl+\ command or via the right click context menu
Windows now provides the Windows Terminal.
Windows Terminal can split the terminal into panes and can also run different shells (i.e. cmd, powershell, and bash through the wsl)
You can install Windows Terminal directly from the Windows Store.
Create a virtual machine where you can run your PowerShell sessions uninterrupted. The PowerShell windows are always where I placed them when I come back.
It could be an expensive solution depending on your needs, but I have been doing this a long time. It's a robust solution since the only user processes on the VM are my PowerShell sessions.

How to remove the language indicator from the Windows 8.1 taskbar via command line?

So, a game I play for some bizarre reason causes the language selector to show up on my taskbar every single time I run it after a reboot. My PC is English (UK) and the game adds English (US).
Once I remove it the first time, it stays removed until reboot. Is there a way I can do it via CMD so I can just have a batch run after I run the game?
To be specific, I am looking for how to do:
R-click Taskbar > Properties > Taskbar > Customize... > Turn System Icons on or off > Input Indicator > Off
via a direct command line, I don't want to make a script to automate the clicks.
You can copy the following two lines into Notepad, save them as HideLang.reg and merge it into the registry:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\CTF\LangBar]
"ShowStatus"=dword:00000003
You'll need to log off then log back on or reboot the computer for this change to take effect.

Terminal window inside Sublime Text 2

I saw this project that basically opens a new terminal window from sublime text-2.
What I'm looking for is a way to open the terminal inside sublime text 2 via console.
Does anyone knows how can I do that?
SublimeREPL does what you want
https://github.com/wuub/SublimeREPL/
Of course, there are some limitations because the window of Sublime Text 2 is not originally designed for continuous running buffer of stdin input.
+ 2 years (sorry) - but my solution in ubuntu was to open both sublime and my (real) terminal in the same window, shrink and stretch the terminal to cover the lower portion of the screen, then right click on the terminal and select "keep on top" - works a treat.
EDIT 04/23/2019: Terminus extends TerminalView & adds:
Windows support
Continuous history
Easily customizable themes (see Terminus Utilities)
Unicode support
256 colors support
Better xterm support
Terminal panel view
imgcat support (also works on Linux / WSL)
Bind key shortcut to open shell on file path (e.g. ctrl+alt+t to open):
{
"keys": ["ctrl+alt+t"], "command": "terminus_open", "args": {
"cwd": "${file_path:${folder}}"
}
}
Original Answer:
I've tried pretty much every terminal package around, what you want is TerminalView:
To bind a key shortcut, simply add it to your user key bindings file:
{ "keys": ["ctrl+alt+t"], "command": "terminal_view_open" },
Use Glue. It is a plugin that provides an interface to your shell from the Sublime Text. So basically it a terminal for Sublime Text.
https://packagecontrol.io/packages/Glue
Like #mikko I also decided that due to the limitations of the shell add-ons for sublime to stick with a real terminal window - I've got too used to the F2-F4 workflow of geany.
So really the issue for me is quickly flip-flopping between the two windows easily. To that end, I knocked this up - to be fired from F12 (or whatever you want) in your desktop manager (XFCE in my case)
Note, I launch sublime a from shortcut with terminator -T st3_bash & st3 so I've got a known bash window title for switching focus to.
https://gist.github.com/robertpearce/8725224
I know this code is really, (really) bad, and it'll fail if you have multiple sublime's open, but i don't ever have that anyhow.
Feel free to fork and improve it.
I have always wanted a way to open terminal inside sublime text. After trying out different options I have come to a solution of installing guake terminal as a work around on linux systems, follow the steps below.
Run the command sudo apt-get install guake
Press F12 (for opening terminal)
Now you can use the terminal without leaving sublime.
For windows :
Install Conemu
Have the Quake settings as shown in the pic below
Press ctrl + ~ (for opening terminal)
Note: This is just a workaround. Guake is basically a terminal package for ubuntu-like linux systems.

Windows Explorer "Command Prompt Here" [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I frequently find myself with a folder open in Windows, wishing to have a command prompt open with the same working directory.
I am aware of Power Toys "Command Prompt", but that only works as a context menu item on the folder, and not from inside the folder if you are already there. I know you can navigate to the parent directory, and use it from there, but if the parent has thousands of directories in it, this is not so convenient. I have tried some home-brewed batch files associated with folder actions in explorer, but those suffer from similar problems.
So, what is the quickest way to open a command prompt with a working directory of the current windows explorer folder?
My current approach: (horrible)
Alt - D, Ctrl - C (copy path)
Win - R, "cmd", Enter (start command prompt)
"cd", Space (start a change directory command)
Alt - Space, e, p (paste directory)
Enter (execute change directory)
I know there is something better! What is it?
Hold Shift while Right-Clicking a blank space in the desired folder to bring up a more verbose context menu. One of the options is Open Command Window Here. This works in Windows Vista, 7, 8, and 10. Since Windows 10 Creators Update, the option has been replaced with Open PowerShell Here. However, there are ways to enable Open Command Window Here again.
Just type "cmd" to location bar, that's it. It will start a new command prompt in current path.
This solution was confirmed to work in Windows XP, Vista, 7, 8 and 10 (including Creators Update).
Keystrokes to move the focus to the location bar:
AltD in English (pointed out by Tim Stewart in the comments)
AltE in German
Inside your current folder, simply press Shift+Alt+F --then--> Enter.
The prompt will appear with your current folder's path set.
Note: That works only in Windows 7 / Vista. What it does is that drops the "File" menu down for you, because the "Shift" key is pressed the option "Open command window here" is enabled and focused as the first available option of "File" menu. Pressing enter starts the focused option therefor the command window.
Edit:
In case you are in a folder and you already selected some of its contents (file/folder) this wont work. In that case Click on the empty area inside the folder to deselect any previously selected files and repeat.
Edit2:
Another way you can open terminal in current directory is to type cmd on file browser navigation bar where the path of current folder is written.
In order to focus with your keyboard on the navigation bar Ctrl+L. Then you can type cmd and hit Enter
Right-click the title-bar icon of the Explorer window. You'll get the current folder's context menu, where you'll find the "command window here" item.
(Note that to see that menu item, you need to have the corresponding "power toy" installed, or you can create the right registry keys yourself to add that item to folders' context menus.)
As a very quick solution I can give you this. I tested this on Windows 8.1
1- Find File and Right Click on Command Prompt on File Explorer and then add command prompt to your Quick Access Toolbar:
2- After adding it you can access the folder from here:
That will open a command prompt in there for you.
On vista and windows 7:
Alt+d -> it will put focus on the address bar of the explorer window
and then, type the name of any program you would launch using WIN+r
hit Enter
The program will start with its current directory set to that of the explorer instance.
e.g.:python, ghci, powershell, cmd, etc...
For Windows vista and Windows 7 ,to open the command prompt
1) go to folder you want to work
2)In address bar type- cmd
press enter
it will open the command prompt for that location
You can edit the registry to add the Command Prompt item to the context menu. Here are a couple of .reg files that I use.
Cmdhere.reg - for WinNT/2000/XP/Vista/7:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\OpenNew]
#="Command Prompt"
[HKEY_CLASSES_ROOT\Directory\shell\OpenNew\Command]
#="cmd.exe /k cd %1"
[HKEY_CLASSES_ROOT\Drive\shell\OpenNew]
#="Command Prompt"
[HKEY_CLASSES_ROOT\Drive\shell\OpenNew\Command]
#="cmd.exe /k cd %1"
Doshere.reg - for Win9x:
REGEDIT4
[HKEY_CLASSES_ROOT\Directory\shell\OpenNew]
#="MS-DOS Prompt"
[HKEY_CLASSES_ROOT\Directory\shell\OpenNew\Command]
#="command.com /k cd %1"
[HKEY_CLASSES_ROOT\Drive\shell\OpenNew]
#="MS-DOS Prompt"
[HKEY_CLASSES_ROOT\Drive\shell\OpenNew\Command]
#="command.com /k cd %1"
Copy this into an empty text file and change the extension to .reg. Double-clicking on this in Windows Explorer will add these key to the registry.
I use StExBar, a Windows Explorer extension that gives you a command prompt button in explorer along with some other cool features (copy path, copy file name & more).
https://tools.stefankueng.com/StExBar.html
EDIT:
I just found out (been using it for more than a year and did not know this) that Ctrl+M will do it with StExBar. How's that for fast!
Almost the same as yours:
Alt+d, Ctrl+c
Win+r
cmd /K cd , Ctrl+v, ENTER
If that's so bothering, you could try to switch to windows explorer alternative like freecommander which has a toolbar button for that purpose.
I use a lot the "Send To" functionality.
I create my own batch (.bat) files in the shell:sendto folder and send files/folders to them using the context menu (to get there just write 'shell:sendto' in location bar).
I have scripts to perform all sort of things: send files by ftp, launch a php server in the current folder, create folders named with the current date, copy sent path to clipboard, etc.
Sorry, a bit offtopic but useful anyway.
Tried the answer given by Tough Coder in Windows 7 and it works!
Create a shortcut to cmd.exe in %HOMEDRIVE%%HOMEPATH%\Links, open its file properties and change the field 'Start at' to %1 ('Iniciar en' translated from spanish).
Now drag folders to it and you'll see the magic. It works too in all standard Open File dialogs. wow!
ps: those 'strange' tabs above in my picture are because I use Clover. I recommend it!
Use the following in command prompt to open your current location in windows explorer:
C:\your-directory> explorer .

Resources