back

by Insanity·9y ago·view on hn ↗
When I started working on Windows again at the end of last year, the first thing I did was pin PowerShell to the taskbar.

I have not used the plain CMD for a long time and would not go back to it. Muscle memory makes me type "ls" in any directory I enter when looking around for something, the fact that PowerShell has this is already a reason for me to use it.

I'm not a heavy PS user though, and feel that it still compares poorly to Linux or Mac's terminal for that matter.

1 comments
The terminal itself is poor, but PS the language is so much more sane and ergonomic than bash. Doing text-in-text-out where the sed/awk/split/sort relies on every program in the chain (perhaps a git log, or an ls or whatever) to spit out its text in exactly the same way it always has just feels like a terrible idea.

Example: count the number of files of each extension in the current direcory and list the results alphabetically by extension (I honestly didn't pick this as a way to show of PS strength and I realize that you can always pick a benchmark that shows what you want - but I wanted something small and understandable).

PS:

    ls | group Extension | sort Name | select Count, Name
bash:

    ls | awk -F . '{print $NF}' | sort | uniq -c | awk '{print $2,$1}'
    
These lines accomplish the same thing, with about the same amount of typing required. You can argue that objects are brittle too, or that text is a universal format whereas objects are not. But you can't tell me the bash line looks better, or that for everyday tasks PS is always a verbose mess. Also: just typing the bash line on my keyboard includes hitting Ctrl+Alt/AltGr eleven times!
I don't see we should have to learn a new language for this at all.

The set based paradigm of SQL lends itself very well to reporting and processing files, and is known by 7 million people.

SELECT extension, count(*) FROM files GROUP BY extension ORDER BY extension;

We built a tool, free for personal use, that does SQL at the command line

http://etia.co.uk

Shells aren't file processing only - you process anything (dates, logs, configs, environment, apps, ...).

Unless the underlying model has all of that, I don't see how it competes with bash/ps

It should be doable but requires more than a filesystem relational model

Select * from processes order by priority

I mean I see the benefit of using Sql, had I mastered it, for files, but I'd be reluctant to sort and group reg keys or users or devices or processes or env vars differently from files in my shell language. You must have a "relational model" for the file system, do you have a way to (or plan to) generalize this to general structured data?

I have not used PS that much so I am not sure how much can be accomplished with it.

One of the great things about a Linux system is that you can use the terminal to install and delete programs. Can you do that with PS without using something like Chocolatey?

Not sure I understand the question. You can always just copy a program somewere, add it to path and so on with both PS and cmd (or script it, the equivalent of "make install").

You can also download and install Windows installer setups from a shell, and also uninstall them e.g by name (more elegantly in PS than in cmd). Because win apps are usually binary this is a more common way than the "make install" equivalent on Linux (Where I don't believe there exists a distro independent binary installer format?)

You can't install apps like "packages" without a package manager like choclatey, but that I assume is the same in Linux, you need to install a package manager like apt or yum if the distro didn't come with one.

Indeed, you have package manager interaction but I think that on most linux boxes that is standard? I could be wrong there though, it just goes for the ones that I have used.

Still pretty meat that you can uninstall a program from PS. Might need to give it a closer look, any suggestions on where to learn it from?

It's not all that standard on Linux under the covers either, because the package manager is a function of the distribution and its ecosystem and there are two main package ecosystems rpm (current package manager: yum) and deb (current package manager: apt) and a very long tail of other package systems and ecosystems. If you stick primarily to a single distribution you wind up mostly fine (until you need packages outside your ecosystem), if you need to interact with multiple ecosystems things get more complex.

The big difference between something like Chocalatey and rpm/deb Linux package ecosystems is more one of scale (how many packages exist in the ecosystem; how many players are expected/required to buy into the ecosystem).

An interesting twist to this is that PowerShell in Windows 10 'recently' added a meta-package manager "OneGet" that was designed to use a single set of commands to learn to work with a wide collection of package ecosystems (including, but not limited to, Chocolatey, NuGet, MSI installers, Docker packages, whatever other sort of provider someone wants to build).

There are several different ways, see e.g http://stackoverflow.com/questions/113542/how-can-i-uninstal...