

Bringing Bash's powerful command line editing to Microsoft Windows' cmd.exe - yanovskishai
http://code.google.com/p/clink/

======
ehosca
Do yourself a favor, learn PowerShell if you have to work on Windows.
<http://technet.microsoft.com/library/bb978526.aspx>

~~~
Graphon
While powershell is a valuable and interesting option, the problem with it is
that it changes the basic metaphor.

For 40 years unix shells and their descendants and derivatives including
cmd.exe have used files and text streams as the metaphor for interconnecting
processes. Powershell changes that, and it means the output of one command
goes to the input of another command as "objects".

This can be powerful, but it is also very disorienting. Which means it can be
hard to learn to do even basic things in powershell, things that would take
only a pipe or two and a couple unxutls programs in cmd.exe.

In cmd.exe, easy things are easy and hard things can be really hard. In
powershell, hard things are hard (as opposed to "really hard") and easy things
are hard.

~~~
gouranga
I'm not a fan of powershell but I have to use it in my line of work.

The only thing that I find sucks is that the pipeline is slow as snails. For
example, an svnadmin dump piped to a file which takes 8 mins in cmd.exe takes
14 hours in powershell...

Apart from that it's bearable!

~~~
e40
_The only thing that I find sucks is that the pipeline is slow as snails._

This is because CreateProcess in Windows is slow. It's the reason that run
make on Cygwin on Windows for not-that-large Makefiles is really, really slow.
The same Makefile on UNIX and Windows differ in startup time by a wide margin.
It's really painful to type "make ..." and sit there for 30 seconds on a fast
machine.

~~~
gouranga
CreateProcess is only being called once in this case i.e. to spawn svnadmin.
The exact script does the following:

    
    
       svnadmin dump d:\repo > repo.dump
    

The output from svnadmin has a lot of lines. Due to the fact that PS is
written on top of the CLR, it reads each line into an immutable string before
writing it to a file. So for every line it has to create a new System.String
object and as another poster said GC it later. Also as lines are not
predictable length it has to buffer them resulting in more overhead.

Effectively where *NIX shells use a fixed size buffer for pipe operations and
operate on streams, PS has to convert it to lines first before writing it out.

That doesn't work when you have approximately 25 bytes per line and a 12Gb
file which is where the issue is.

~~~
shortlived
I can appreciate the technical explanation as a programmer, but as an end-user
of PS: I don't care. It's slow.

~~~
gouranga
For the majority of tasks it's fast enough. There are a few edge cases though.

------
projectileboy
Is this different from Unix Utils? Every gig I've ever been on where I'm
forced to use a Windows box, first thing I do is load the Unix Util exes into
some directory and add it to the path. <http://unxutils.sourceforge.net/>

~~~
pudquick
If you like unixutils, you might like GOW a bit more:

<https://github.com/bmatzelle/gow/wiki/executables_list>

<https://github.com/bmatzelle/gow/wiki>

Kept up to date, every .exe (once installed) is self-contained (no external
.DLLs) and portable to just about any Windows box I've run into.

No Cygwin or MinGW installation required.

Bash is actually available in the list (albeit an older version) if you really
wanted "bash on Windows"

~~~
mih
Thanks. I used to use GNUWin32 (<http://gnuwin32.sourceforge.net/>), but this
seems like a good alternative.

~~~
to3m
This was my thought too, but I pushed GOW to a lower priority in my to-do list
after a comment in a recent thread that publicised it:

<http://news.ycombinator.com/item?id=4085830>

------
slu
Looks sweet.

I currently have to use Windows at the customer I'm working for. I've
installed Console which gives tabs and better copy-n-paste on Windows. See
<http://sourceforge.net/projects/console/>

I'm not sure if clink and Console will work together, but I'll have to try it.

~~~
ot
Console2 regularly crashes on my Windows 7, and it looks like it's not
actively developed.

I'm giving ConEmu a try and it looks awesome!

<http://code.google.com/p/conemu-maximus5/>

Scott Hanselman wrote a blog post about it:

[http://www.hanselman.com/blog/ConEmuTheWindowsTerminalConsol...](http://www.hanselman.com/blog/ConEmuTheWindowsTerminalConsolePromptWeveBeenWaitingFor.aspx)

~~~
daliusd
Console2 looks releases 1-2 releases per yer. Looks quite stable while not
active as some other projects. Check dates here:
[http://sourceforge.net/projects/console/files/console-
devel/...](http://sourceforge.net/projects/console/files/console-devel/2.00/)

------
gouranga
I've switched to powershell ISE on windows (shipped with it) rather than cmd
hosted powershell. Does the job!

~~~
omaranto
Is it worth installing .NET 3.5 to run the ISE? I use Powershell but only have
.NET 4 which runs it just fine. I'm a little surprised that ISE requires 3.5.

~~~
gouranga
It doesn't make any difference. It required 3.5 as win7 shipped with that
framework. You may actually have 3.5 installed already. Check for the
following dir: c:\windows\Microsoft.net\framework\v3.5

If it's there you have it already.

------
alanbyrne
What's wrong with Powershell?

~~~
est
starts too slow.

~~~
pjmlp
on my PC it is instantaneous, it is a matter of hardware.

~~~
shortlived
No, it's not. I have a TI6x laptop, 4gb of RAM, plenty o' CPU and with no
other user-space programs running, it still takes FOREVER to start. I feel
like i'm launching Eclipse or something.

~~~
pjmlp
Try it on a T410, i7 with 8GB of RAM and a SSD, it takes 2s to start.

~~~
shortlived
it's a SHELL for God's sake! I shouldn't need 8GB and SSD!!!

------
38leinad
just use cygwin

~~~
ot
I feel like cygwin manages to combine the worst of UNIX and the worst of
Windows. And the commands that use the cygwin runtime are noticeably slower
than the native counterparts.

Also, AFAIK there is no 64bit version yet, which for me is a dealbreaker (I
often work with files larger than 2GB).

~~~
EvilTerran
I'm with you there -- I find Cygwin starts slow and unstable, and then seems
to rot at an astonishing speed, to the point where it's usually unusable after
I've had it installed for a couple of months.

~~~
barrkel
Cygwin doesn't rot. It doesn't automatically update, and nor does it self-
configure, so there's nothing to cause the rot. I've never had problems like
you describe.

The biggest problem - and what I suspect is happening to you - is when you
have third-party programs and utilities that interfere with Cygwin, most often
by putting an older or newer version of cygwin1.dll on the $PATH (i.e. you may
be using Cygwin as part of some other program and not be aware of it). Cygwin
uses shared memory; multiple versions of cygwin1.dll disagree on the format of
this shared memory, and things go pear-shaped pretty quickly from there.

Also some antivirus programs can trip up Cygwin; in its emulation, it
sometimes has cause to open, close then open files in quick succession, but AV
programs sometimes analyse files when they are opened by programs, and cause
bogus timing-dependent sharing errors.

~~~
EvilTerran
"there's nothing to cause the rot"

The rot tends to set in as I install packages to Cygwin; the more I add, the
slower and less stable Cygwin seems to become, to the point of taking tens of
seconds to reach a prompt after opening. Make of that what you will.

"Also some antivirus programs can trip up Cygwin"

That could well be a contributing factor in my case.

~~~
cygx
Did you try disabling bash completion[1]?

[1] [http://cfc.kizzx2.com/index.php/tag/cygwin-slow-
performance-...](http://cfc.kizzx2.com/index.php/tag/cygwin-slow-performance-
bash-completion/)

~~~
EvilTerran
No, I didn't -- good spot, thank you.

I haven't bothered re-installing cygwin since the last nuke-and-pave, but I'll
bear that in mind if I do and it's still relevant.

------
malkia
Or just use Far Manager - <http://www.farmanager.com> \- it's Midnight
Commander, Norton Commander type of program.

~~~
shortlived
I've watched numerous Russian colleagues use it and it does not look
appealing. These same colleagues do not seem to understand the power of a real
*nix shell. You end up doing less typing if you really know your shell and how
to pipe etc.

~~~
malkia
You can run cygwin shell from FAR, or any other shell. Seriously.

Think of Far Manager as Midnight Commander, more or less.

------
Bjartr
Why use this over a cross-compiled version of Bash?

