3 ms·
I use Powershell as my default command shell (via ConEmu). But its verbosity makes it a pain to work with as your everyday shell. For instance, in cmd.exe you c
by smithkl42 10y ago
I use Powershell as my default command shell (via ConEmu). But its verbosity makes it a pain to work with as your everyday shell. For instance, in cmd.exe you can say:
dir /od
But in Powershell, you have to do:
dir | sort-object LastWriteTime
I totally get the Powershell verbosity when it comes to writing scripts. But it can be a PITA when you're using it interactively.
- latkin 10y agoFirst off, if you are using built-in `dir` alias, why not use the `sort` alias? Note also that you get tab completion for `dir`, `sort`, and `LastWriteTime`, so "verbosity" becomes decoupled from "speed of entering commands", which is the real goal. dir | sort LastWriteTime I think many in the "Powershell is too verbose for interactive use" camp have simply been trained by cmd to have a very narrow view of what is appropriate for interactive shell execution. Cmd's syntax and toolbox is so poor that only the simplest of tasks are considered tractable for interactive scripting - doing anything non-default is incredibly difficult (or impossible) without a dedicated flag on some windows util (e.g. `/od`). Thus you come to a state where the only commands anyone enters interactively in cmd are very short and simple - not because the language is concise but because it's too painful to attempt anything more. Translating that narrow set of cmd-suitable tasks into Powershell, one finds that indeed on average Powershell is a bit more verbose, and one says stuff like "Powershell is more verbose than cmd". What you're missing is that Powershell actually gives you a general, complete, and uniform set of tools, which really are fairly concise given their power. The space of tasks which are now suitable for interactive scripting is now vastly larger. So before you say Powershell is "too verbose", I ask how concise batch/cmd is for the following tasks: # assign earlier result to a variable (quite hilarious the gymnastics cmd makes you do simply to assign stdout to a damn variable) $x = dir | sort LastWriteTime # sort by the modified *date*, then by filename dir | sort {$_.LastWriteTime.Date},Name # get the sum of file sizes in the current dir, in MB (dir | measure Length -sum |% sum) / 1MB Many would reply to this with something like "well if I need to do something like that I'd be using C#/Python/VBS". That's my point! With powershell you have a great interactive shell for super short stuff like file copies or `dir` listings (not the case for C#/Python/VBS), but ALSO the ability to do powerful general scripting with one-liners in the shell. My "everyday shell" usage frequently covers scenarios similar to or more complex than my examples above. I am quite happy to pay a minor verbosity tax on the trivial commands so that I have the power to do the non-trivial stuff without leaving the shell.