4

I'm having issues with Cygwin's Copy/Paste functionality on a fresh install.

If I scrunch my cygwin window small, and then type a command that is wider than it is (such as echo testestsetsetestestsetsetsetsetsetsetsetset) and hit enter, the command executes successfully.

If I then copy that command from the cygwin window and paste it in, say, Notepad++, the command has a line break in it where the line wrapped in the window. What this means in practice is that if I paste that command into cygwin again, it'll think it is two commands, which is not correct.

How can I get cygwin to not write a newline character in the line breaks (my old installation did not have this problem btw. Something about new cygwin/windows 10/some bad setting is causing this).

  • 2
    which terminal are you using ? It works fine for me with Mintty on W7 – matzeri Apr 26 '16 at 5:45
  • 2
    If you start bash.exe from cmd it will show this behaviour. As @matzeri says, it works as you would expect in mintty.exe, which is how it is launched from the start menu. – AFH Apr 26 '16 at 12:23
  • @matzeri I'm not using Mintty, I'm using vanilla Bash Cygwin - I run cygwin.bat from the Cygwin install dir. If I use mintty, can I still use products like Console2? – Cody S Apr 26 '16 at 15:45
  • @natzeri Ok, I understand the questions better now. I'm typically using ConsoleZ as my terminal, but this problem happens using bash as well (read: using cygwin.bat). But you're right, using Mintty, the issue doesn't occur. So that's odd – Cody S Apr 26 '16 at 15:53
  • 1
    cygwin.bat is not a proper terminal. Mintty is cygwin aware terminal – matzeri Apr 26 '16 at 18:01
1
+100

The best solution I have for this so far is something like this:

echo "1222222222222222222222222222222222222222222222222..." > output
notepad++ output

assuming you can run a GUI editor from the command line. Surely you can just open it through the explorer.

Another method I use is putclip:

echo "1222222222222222222222222222222222222222222222222..." | putclip

then you can use regular paste command to paste

| improve this answer | |
  • 1
    I doubt he wants to copy&paste the output of a command, since as he described, he's then trying to paste it back to the terminal. He wants to copy&paste the command itself. Although your answer may be useful, it won't help to OP. – David Ferenczy Rogožan May 2 '16 at 23:36
  • Yeah, this isn't really what I was looking for. I'm more interested, from a technical point of view, why Mintty works just fine, but Console2 or ConsoleZ or ConEmu don't work properly... – Cody S May 2 '16 at 23:45
0

The problem can be solved from within a mintty session by running "screen" (e.g., from your .bashrc). Although text will wrap-around from within a "scrunched" terminal, copy-n-paste will do what you want, and the wrapped text will even "unscrunch" if you widen your terminal after the fact.

Screen can be installed from the cygwin installer under the "Utils" section.

Here's a link to the usage page, it's a fabulous environment with many other advantages as well. Here's a good intro page:

http://aperiodic.net/screen/quick_reference

In case it matters, I launch my terminal from a windows shortcut with the following command:

C:\cygwin64\bin\mintty.exe -o BackgroundColour=#D8FFE0 -i /var/myterm/blue.ico -

The 'blue.ico' is a copy of c:/cygwin64/cygwin.ico (icon color edited to match background color).

| improve this answer | |
  • I just noticed the comment in the Bounty box referencing "ConsoleZ", which I don't have installed, and haven't tested. – philwalk May 2 '16 at 14:44
  • As I mentioned, Mintty works fine, but Console2, ConsoleZ, and ConEmu do not. I'd rather use any of the latter 3 than Mintty, and can't figure out why Copy/Paste has confounded those wrappers – Cody S May 2 '16 at 23:45
  • I installed and verified the problem from the latest ConsoleZ (x64), sorry I couldn't help. – philwalk May 3 '16 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.