Microsoft is making the Windows command line a lot better
arstechnica.com
arstechnica.com
As for TFA, this is astoundingly overdue. This most recent gig involves using Windows for the first time in years. No worries, I'll load that new WSL I've been hearing about. Hey, look! A bash shell! On Windows! What will they think of next?
Except it's wrapped in a Windows console, which blows goats just as much as it ever did, the evidence list for which I need not repeat. MSFT can make some damned nice GUIs for simplifying complicated tasks. I guess the fallout is that their text-based UIs don't get as much love.
Lynx isn't a CLI program. Curl is a CLI program. I agree that it's preferable to use Firefox over Lynx, but all of that works fine on X11. The point of Windows is it does everything using graphical interfaces.
Really? There's people who'd say
> The point of Linux is it does everything using the command line
Which would also be inaccurate.
You're going to center a technical discussion around what the marketing department decided to call it? Windows does much more than draw pretty pictures on the screen. I would think this to be common knowledge amongst the HN crowd.
That's not even remotely true: https://msdn.microsoft.com/en-us/library/ee391626(v=vs.85).a...
You're knowledge of Windows is either lacking or based on misinformation. Which is fine, but it's probably not worth arguing the point anymore.
It might be the right thing, but relatively few actually recognize it as such, even if developers often do.
But what about everything else? Productivity, gaming, browsing?
I am pretty ok with Powershell and the state of command line on Windows since ever.
Practical example from a few days ago: here's feross' script to find compromised eslint-scope for Linux/Mac.
find . -type d -name "eslint-scope" -print0 | xargs -n 1 -0 -I % sh -c "(cat %/package.json | npx json version) && echo '(at %)'"
Here's an equivalent for Powershell: $results = @{}
ls -recurse -filter "eslint-scope" | foreach {
$file = "${_}\package.json"
$version = cat $file | convertfrom-json | select -ExpandProperty version
$results.Add($file,$version)
}
echo $results | format-list
Rather than scrape for regexs, you're using objects.Rather than using xargs to iterate, you're actually iterating. JSON is built in, you use 'select' to pick the property you want. Formatting is seperate from presentation.You can use (and probably should) use Python on nix for similar cleanliness, but Powershell does all this and still feels like a shell. It supports emacs bindings (you use emacs binding on bash by default, regardless of which editor you use), readline, you have a profile, and all the good things you expect from *nix (Windows /terminals/ generally suck, but using the inbuilt terminal with groupy it's decent). It's just way nicer, at the expense of a little learning.
Also, you can totally pipe into while in bash. There is no need to use xargs there. You can even deal with spaces in filenames if you need to...
I've used bash for 20 years, worked at Red Hat and IBMs Linux Group and my name might be in your OS. I switched from bash/python to Powershell.
> It's hideously inconsistent
How so? It's the only shell I've ever used where you can guess most commands. That's a massive achievement.
> There is no need to use xargs there.
Sure, I'd just use -exec and a fat lady. The example still shows the differences between
- treating everything as strings then scraping with regexs and other string manipulation tools
- using objects
> You can even deal with spaces in filenames if you need to...
A file name is an attribute of the file (inode/fileID). If you have to think about whether a file name has spaces or not you're scraping, rather than treating it as a single string-type attribute. This is why bash has a reputation for being brittle.
Really painfull.
Please don’t tease me... It’s been a long time coming. Hope they deliver.