More power, less shell

[I wrote this post last year...expect an update soon.]

I'm a big command-line user. Under Windows. There aren't so many of us, but I'm a yet rarer breed that hasn't been using CMD.exe, WSH, or PowerShell. Instead, I've been using this ancient shell called Take Command Console, or as I've called it for years and years, 4NT. I first began down this road back in the days when it was 4DOS, the better DOS replacement (and later, 4OS2...that brings back memories).

The folks at JPSoft, who've been making 4NT, etc., have been working steadily to add various features to it which I have completely ignored. Then they abandoned the 4-products and upgraded to a windowed terminal app called TakeCommand. Which I tried, but just too much stuff was broken. I guess I push my console usage pretty hard. So I stuck with their legacy product until it was so neglected that JPSoft just released it for free to make people like me go away.

Why the weirdo shell?

Why did I use it?  The features I used every day were:

  • Better filename completion
  • Aliases
  • Colored directory listings
  • Support for CDPATH functionality
  • The ability to set a network share directory as my current directory (seriously, is it really 2014 and we're still using shells that can't do this?!)
  • Search through command-history by default tied to up/down arrow (like bash's Ctrl+R, but much more sensible)
  • A nice little feature I haven't seen reproduced in any other shell, of shortcutting ..\.. to ..., ..\..\.. to ...., etc.

Not rocket science, but daily productivity enhancers. Yeah, there were all kinds of new scripting features, but what do I care?  Perl, Python, Ruby, etc.; why on earth would I waste my time in the dark ages of a slightly enhanced CMD (or, for that matter bash, zsh, or any other fine shell which makes for a horrible programming language).

Seeking a modern replacement

But 4NT, as I insist on calling it, just isn't cutting it anymore. I had a thing which extended my command prompt for Mercurial support, but it was...well, let's just say I would rather have been writing BAT files. Have you ever programmed using raw ANSI escape sequences?  If so, I feel your pain.

So, you might ask, why haven't you been using PowerShell?  Good question. Mostly because I just didn't feel like taking the time to learn yet another shell. But I finally started doing so this weekend. And I'm having a mixed reaction.

PoSH, the good

Clearly, PowerShell is powerful. I can access the windowing system, I can trivially configure my command-prompt, I can spit out color with minimal insanity (still limited, alas, by the basic limitations of a 1993 Windows NT console). It only took me about 5 minutes to figure out, for example, how to get a PowerShell launched in Admin mode to detect that it was Admin mode and default to different background/foreground colors. Which was absolutely impossible to do programmatically elsewhere.

PoSH, the bad (TL;DR)

But PowerShell wants too much to be a language. To grow up and play in the same playground as serious scripting languages (most of which, interestingly, are trying to shake off the moniker of scripting language altogether). And darn it...what I was looking for was a shell.

PowerShell provides replacements for many DOS and Unix commands. And they really are replacements...simply aliases for PowerShell commands. And advocates would tell you they're better. Well, except when they're not. dir gives you more information, but doesn't tell you how much total space your files take, or give you free space on your drive. You can cd to a UNC network share, but you can't start it and end up in the right directory. And nothing accepts command-line arguments. So how do I sort my directory listing by creation date? How do I recursively remove a directory (best answer by far: cmd /c "rd /s /q")? You know, good old CMD solved these problems in about 8 keystrokes. As does pretty much every other shell on the planet since DOS 3 and Bourne shell.

It's just one frustration after another. And they don't even get all of the scripting stuff right. I've found several versions of the Unix df command implemented in PowerShell. And not a one of them will give me information about a UNC share. Although they do tell me that my logical drive network shares are using upwards of 200% of their disk capacity.

But then I look at something like git-posh. And that's just so easy. And readable. Compared to my comical attempt to integrate hg-prompt into 4NT:

set cmdprompt=%@execstr[hg prompt "^e[46;1m#{rev}^e[37;1m{:{branch|quiet}}{/{patch}}^e[31;1m{status}^e[0m" >&> NUL])

Sigh

So, what to do? Maybe I'll do something crazy like re-alias dir and rd to use cmd. Maybe I'll toss the thing entirely and switch to cygwin bash, where I've already invested extreme effort into improving tab completion for my Mac, paired with the insanity that is Unix-style pathnames on Windows.