20 ms·
A Saner Windows Command Line
- ekianjo 11y agoWhy would you even want to make Windows command line better, instead of using a state of the art command line of Linux via a VM running in Windows, if you really cannot escape the Windows realm ?
- DominoTree 11y agoBecause a VM is overkill and won't allow you to interact with the Windows host.
- gutnor 11y agoWindows used to provide Interix which was a subsystem that allowed use to use quite a bunch of posix utilities and offered quite a very good integration with Windows. You could do quite a lot of things with it (we used it to convert a unix app to windows in record time) and it was IMO superior to Cygwin. But that was 10 years ago, it disappeared at some point, being integrated somewhere in either the server version or the professional edition (named something like Unix Service for Windows) I lost track. Considering all the work that MS is putting in interoperability those days, I'm wondering if it will not make a come back at some point.
- ekianjo 11y agoGood luck with file permissions on the Windows host. You are in for a fun time.
- TallGuyShort 11y agoBecause not everyone shares your opinions. I'm not a fan of Powershell, but one thing I love about the design is that it works on objects, not text. UNIX philosphy relies heavily on text and it keeps some things simple, but when you need to move beyond that to more complex structure, the UNIX command-line starts breaking down, whereas Powershell pipes, etc. continue to do well. There are good ideas out there beyond "just use Linux."
- douche 11y agoIf the Linux command line is state of the art, then the art hasn't advanced that far. Too much of it is frozen in time, with constraints from PDP-11s with two-tone 80-char displays, and insane, arcane UI that made sense to the wizards of that day, but less so to we mere mortals. Lots of inertia there. Still CMD is worse, and Powershell is different, but maybe not any better...
- ezoe 11y agoI don't use Windows anymore so I don't care much. But, When does Windows offer a terminal emulator with sane character encoding(UTF-8)? This is 2016, CP932(Shift JIS with IBM extension) shall be abandoned.
- alimbada 11y agoI've been wanting bash style completion in a Windows Command Line for so long. Big thanks to the author for the PSReadLine tip; it works perfectly in ConEmu whereas Clink wouldn't work at all.
- gpvos 11y agoI tried both ConEmu (twice) and Console2 in the past, but both were too unstable for regular use. If someone can convince me that the situation has markedly improved, I might try again, but I guess I'll just wait until we upgrade to Windows 10 at my workplace (which they say is any day now).
- DominoTree 11y agoConEmu does seem to have gotten a lot more stable in the last few months
- bmj 11y agoI'll confirm this. During a previous project, it would sometimes crash, or history would get wonky, but I've not seen any of those behaviors while working on my current project. I generally am just using the terminal to run tasks, so I'm not sure I qualify as a "power user."
- rents 11y agoI have been using ConEmu since December and I am yet to run in issue. I use it with Gow and clink. What issues did you face?
- gpvos 11y agoCrashes of the console, usually happening after executing a few commands. This was a few years ago, probably on WinXP, but could be Win7 (I'm on Win8.1 now).
- krylon 11y agoI use ConEmu daily. I wouldn't call myself a power user (e.g. I never have more than five tabs open at once), but I do use it regularly for a number of tasks. In the past, say, six months, I cannot remember having any trouble with it.
- a3n 11y agoHappy ConEmu plus clink user for at least a year, I suspect more, but I don't keep track, I just move on.
- Pxtl 11y agoAt our office we jokingly refer to powershell as "two googles per line" - a term coined by its strongest proponent at the company. It thought it would come naturally over time, but it never does. It seems needlessly cryptic and verbose in so many ways. I've started using LinqPad for stuff I would normally do in cmd now.
- ilek 11y agoAgree on that one, it's really verbose and ugly. I liked the idea of a cmd that integrates so nicely with .NET but I don't think it worked out this time. We use powershell a lot at work for developer setup stuff and other common tasks we do on a daily basis and at this point I've considered just writing my own language to do it or find something else.
- mattmanser 11y agoWhy don't you just use Python, Ruby or even C#? Why write your own language? I wanted to learn Ruby a while back but didn't have a web project to work on so I started writing a load of scripts in Ruby instead. It worked out fine.
- ilek 11y agoC# has the same issue really, although we do it use for some other tooling and whatnot as we're a .NET shop. Don't know much Ruby or Python to be honest so I'm not sure how could I apply them but I'll dig around sometime soon.
- UK-AL 11y agoLearning Bash is just as cryptic. At least powershell function names have logic behind them.
- Klathmon 11y agoI've only been working professionally with linux for 5-ish years, but i'd say that i'm still at the "2 googles per command" number for bash. Some of it stems from the fact that i just don't use it enough, but most of it from the fact that this shit just isn't intuitive. why is -b the flag for key length in ssh-keygen? Why is -v the flag for "don't include" in grep? I have those memorized now, but there is no way they are "intuitive".
- andkenneth 11y agoMost of my issues with windows command line have been solved by installing the unix tools to the path when installing git. Provides most of the commands I need (including a native ssh that works from the windows+r dialouge) and I have mingw if I need to do something with bash itself. This on windows 10 with it's nice new command window is pretty nice, but I still do anything serious on my macbook.
- CraigJPerry 11y agoPowershell and its long winded cmdlets are really hard for me to like. I always fall back to cygwin on windows. I once wrote a PS script to set some power management options on a corporate laptop. The script was 11 lines long (vs 3 lines in Python), it was harder to read and understand. Even with ISE available it was much harder to write. I followed along with some exchange server tutorial where the prescribed easy way to achieve the task was a completely unintuitive PS script. I kept thinking about how much easier that particular config change was to make on a Linux host running postfix. I can't see what benefit PS has over cygwin bash but I'd love to hear ideas because PS comes installed out of the box where I have to install cygwin myself.
- sz4kerto 11y ago> The script was 11 lines long (vs 3 lines in Python), it was harder to read and understand. Note that this might be true for one script, and the opposite might be true for another script. Something is saner in bash, something is better in PS. They have fundamental differences (text- vs. object-based), and neither of them is better than the other in all scenarios. (At least that's my experience.)
- Touche 11y agoI think it's worth noting that powershell is .NET object-based. This means you can interact with powershell objects from a .NET language but not, for example, python. To me this is the fundamental flaw of PS. It's a neat idea as long as you stay within their box, within their ecosystem. With Bash you get a wealth of tools because everything can handle text.
- wolfgke 11y ago> With Bash you get a wealth of tools because everything can handle text. I think technically it should be no problem to write some package for most programming languages for interopting with .net objects. In this sense about everything could also handle .net objects.
- Aleman360 11y ago
- SeanDav 11y ago> "And, purely subjectively, I think the .ps1 syntax is a lot more readable than the old .bat syntax." The Author does say "subjectively" but in my experience, both personally and with others, the reverse is true. Powershell can seem to be really cryptic.
- sz4kerto 11y agoBash can be _extremely_ cryptic as well, we just learned it over time. Look at awk :)
- agumonkey 11y agothen perl, then python, then bash.
- typon 11y agoWhy use bash when you can use Python with os and sys modules?
- TallGuyShort 11y agoI prefer Python when appropriate, but if you're going to "shell out" a lot and pipe a bunch of commands together it starts getting too verbose and loses it's elegance. I agree with other posters that bash is not intuitive, but if you've worked with it for a long time, there's nothing like being able to cat | grep | sed in a one-liner, rather than creating a bunch of Process objects, etc.
- deleted 11y ago[deleted]
- tkubacki 11y agoWindows is no go for me as long as there will be no option to use ansible from cmd - fortunately you can manage windows box from OSX or Linux box with ansible
- hobs 11y agoI think a lot of the hate on powershell is that it chooses to do things very similar to existing languages, but just different enough to confuse practitioners of anything else. Posh also suffers in its somewhat easy to invoke any .NET library, so people start comparing it to a more tooled programming language or something with more sane libraries, and the "ISE" is nowhere close to an IDE (why isnt powershell a first class citizen in visual studio! yes I know there are tools, they are not great.) Nonetheless, after a few years of working in sql server I have adopted more and more posh in my life because its simply the fastest way to get things done if you are doing windows server management. I usually find myself on one of these two places if I am looking for something: Mike Fal (SQL Server focus, he is great) http://www.mikefal.net/ http://www.mikefal.net/ Hey Scripting Guy! https://blogs.technet.microsoft.com/heyscriptingguy/ https://blogs.technet.microsoft.com/heyscriptingguy/ edit: forgot to mention that MSFT helped to cause problems by massive changing how the language did things over time(usually for the better), so ps1 vs ps4 is crazy different, another reason to be annoyed because which version comes with which product is a fun skew to deal with (thanks sqlps having ps2.0!)
- agumonkey 11y agoNo mention of clink ? surprising, cmd.exe meets readline. Highest ROI 'update' I know on Windows https://mridgers.github.io/clink/ https://mridgers.github.io/clink/
- lolive 11y agoGit for Windows is bundled with Git-Bash. A very Linux-like commande line. Works like a charm. I also use MobaXTerm as my Putty replacement. It also comes with a Bash terminal that works fine. Very handy! (Two reasons why I love to have learnt Bash)
- chombier 11y agoGit for Windows is probably the first thing I install as soon as I log into a new Windows computer. Granted, bash may not be the most intuitive shell ever, but it just works about everywhere and this is a huge advantage when switching OS regularly.
- ohitsdom 11y agoI develop on Windows and use cmd.exe daily (for simpler tasks like running Gulp or PhantomJS). It's hard to overstate how much of an improvement Windows 10 brings to the command line. Keyboard cut and paste, resizing, better text selection seem so wonderful. It's a crime it took Microsoft this long for these simple features. There's also other handy improvements, like typing "cmd" into the file explorer location bar to open a command window to the current location you are viewing.
- breck 11y agoYes! I joined Microsoft 2 years ago, prior to that was on OS X. I couldn't believe how awful cmd.exe was. It was like if a college student half implemented some homework assignment and we all had to use it. I tried using cygwin, PowerShell, and other shells but that was hard because too much of my day to day work depended on shared scripts that I would have to manually update for my shell. So I was stuck with cmd.exe and it was miserable. Windows 10 fixed that with the improvements you mentioned. It's still no "Terminal", but it's now about 80% as good, instead of 1%.
- maratc 11y ago> One of the reasons you use Windows is so you don't have to use the command line. It's the other way around: One of the reasons I don't use Windows is because I have to use the command line.
- rottyguy 11y ago>> Let's be honest. What many people think of as "the default Windows command line", cmd.exe, is atrociously bad. Selection is awkward, resizing is hard, the syntax is arcane, the list goes on. If you do nothing else, there are two things you can do to make the basic, vanilla experience bearable. Funny, from a guy coming from Windows to Unix I think the exact opposite. Each command comes with a bazillion options and the defaults are simply atrocious (to read the man, oy). Yes I understand that you can tailor each command in some startup script but why? It almost feels like every command needs to be created to solve 5 million things when 99% of the time you use it for 1 or 2 things. A few of my favorites: Scripting: A = 123 vs A= 123 vs A=123 should be the same! Please use trim() in your program when parsing tokens! Keyboard: Please, for the love of god, make the keyboard behave like a keyboard. I don't want to be logged into some terminal and have the Backspace not behave like a backspace (^H??). Yes, I'm sure I can make it work via some, again, configuration magic or enter emacs mode, but, again, why? cd.. should just work. </rant> Having been on unix for the last 7mo after years of windows, I do like some things but let's not be too quick to call the kettle black.
- wernercd 11y agoThis is the Android vs Apple paradigm. Customization available to a fault vs "appliance" that just plain works... Each has their strengths and pain points. There's a reason normal people use Windows and Power Users gravitate to Linux.
- dr_zoidberg 11y agoI'm a power user and I work in Windows(+Python). I absolutely hate compatibility issues on stupid stuff that plague almost every Linux distro. And when there aren't (oh the rare few cases), then you have to compile half the libraries in the system again (take the hint, Debian!). The only distro that was bearable was Mint, and then we got the poisoned ISOs. So, Windows+Python it is. If you really miss the command line utils, theres the GNU Core Utils package to solve your life (though pipes still behave slightly different and that may show in a contrived command).
- onli 11y ago
- emodendroket 11y agoI guess it's heretical to say this in some circles but I really like PowerShell, despite its faults. An object-oriented shell is a really good idea that saves a lot of time trying to munge texts with regular expressions and such. That said the return semantics stink.
- jug 11y agoI think Powershell is a huge leap beyond Command. I just wish scripting was easier with it, speaking of its return values: http://stackoverflow.com/a/10288256/9744 http://stackoverflow.com/a/10288256/9744 Maybe there are better programming patterns for me to use here. Coming from traditional imperative languages, I was confused though, especially when I got to nests of functions, return values, and debug outputs. I mean, I later understood why things worked like they did -- I just had a hard time wrapping my code around the philosophy. Which is unusual for me to have with a language from Microsoft in their post-.NET era.
- diego_moita 11y agoTo hear bash-people to call Powershell "non-intuitive" sounds like those immigrants that go to a foreign land, refuse to learn the local language and insist on the natives to understand their immigrant language. Or like programmers that think that every programming language should have the C syntax. Bash and Unix commands are only "intuitive" after years of practice; Powershell is not different. And it doesn't have any obligation of being equal to bash.
- tacos 11y agoWindows fanboy here. Powershell made the mistake of combining a bad command prompt with a bad scripting language. It is not a "shell" at all. It is bad Python. The excessive verbosity and object safety is great for admin scenarios where you don't suddenly destroy your corporate email transition because of a VP with an apostrophe in her name. But at that point perhaps you should just use C# instead? But for everything else it just looks nuts to outsiders. That's why even the MS developer groups are releasing command line tools cross-platform that behave like Unix apps, not PS monstrosities. https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/ https://azure.microsoft.com/en-us/documentation/articles/xpl... Powershell should be a feature that draws people from AWS. Instead it is seen as a drawback, even inside MS.
- UK-AL 11y agoSimply stating something is bad, without anything to back it up, doesn't make it bad. Learn some alias's if you don't like the Get-X style of functions. gal * | more Will list tons of alias's for you.
- tacos 11y agoGot a directory full of files with underscores in the names? Want spaces instead? Easy, type this: dir -recurse | where {-Not $_.PsIscontainer -AND $_.name -match "_"} | foreach { $New=$_.name.Replace("_"," ") Rename-Item -path $_.Fullname -newname $New -passthru } EDIT: I purposely posted the first Google result. You obviously Googled as well as your code got it backward. But really, why isn't it this? It's worked since the 1980s. You'll dig it since it uses extra apostrophes. rename '_' ' ' *
- jupp0r 11y ago> I know what you're probably thinking. One of the reasons you use Windows is so you don't have to use the command line. I know what I'm thinking. One of the reasons I don't use Windows is that its command line is a second or third class citizen.
- hodwik 11y agoRight. I don't understand how people get any real work done on a Windows machine. What should take 2 seconds to type takes 20 seconds to find in godawful menus, that get harder and harder to find with each new version of Windows.
- gr3yh47 11y ago>Upgrade to Windows 10... the benefits really can't be overstated. except that there's tons of drawbacks to counteract said benefits. Privacy notwithstanding, power-use has been fractured and the flow of configuration ruined in 10
- dolguldur 11y agoanybody tried cash [0] ? [0] https://github.com/dthree/cash https://github.com/dthree/cash
- Poiesis 11y agoI don't really care about "It's Just Text" vs "Data Typing FTW." There are different tradeoffs at play here, and to my mind that's ok. I'm just thrilled to have something that's: - Internally consistent - Well documented - Available by default - Full featured - Still being improved Sure, I'm not thrilled with having to learn another language to get anything done. But it's so much better than what came before that I don't care. Besides, Bash and friends certainly have their quirks as well.
- T3RMINATED 11y agoHow about you just get CMDER its so much better than anything has grep and ls and wget and curl etc... Windows Friendly... http://cmder.net/ http://cmder.net/
- kuma4 11y agoI didn't expect there were a lot of people who knew well about PowerShell here. I like PowerShell.
- joewrong 11y agohttp://scoop.sh/ http://scoop.sh/ has been a nice-to-have tool, similar to homebrew on osx
- bediger4000 11y agoOne of the reasons you use Windows is so you don't have to use the command line. But sometimes it's unavoidable—maybe you need to do some advanced git-wrangling, or you're developing in an environment with CLI-based tools that are far more mature than their GUI counterparts. This viewpoint is just plain wrong. Since GUIs typically don't have a way of doing sequences of commands other than clicking and waiting, then clicking again, or of automatically making decisions, the biggest reason to use a CLI would be to express things that you can't with a GUI - like anything that requires a flow-of-control with if-then-else. After all, that's one of the reasons that rebuses are fun - they're indeterminate and it's fun to de-ambiguate them. It's less fun to have to do all de-ambiguation yourself, when a simple pipeline or while-loop would do the trick.
- latkin 11y agoI did Windows dev exclusively for a long time, and was an early Powershell adopter. Recently I switched companies and now I swap back and forth from Win10 (PS v5) to OSX (Terminal). I'm massively more productive in Powershell, mostly due to my inexperience with Unix. There are a few things I think I can legitimately argue, though: The power of the unix command line is mostly from the utility commands themselves, not from the shell language/ecosystem. Nobody seems to be super enthusiastic about bash as a language (see all of the "at this point I just go to perl/python/etc" comments), but the commands themselves are super powerful and flexible. If you put in the time to really learn the commands and their flags, you can do quite a lot. Watching experienced unix users at the prompt, I routinely think "oh nice, that's a great command to have", but rarely "oh that's a handy language feature" or "wow Bash made that really easy". With Powershell, it's kind of the opposite IMO. The language and ecosystem are mostly well-thought-out, consistent, and powerful. Everything-is-typed, pervasive and awesome tab-completion, mature pipeline system, decoupling of data and how it's displayed, access to the .NET standard libs, ease of extensibility and scripting (oh god it's so nice never neededing to parse arguments!), reflective help system and discoverability features, easily hostable in other apps... That all comes from the ecosystem. Where Powershell often falls flat is the limited set of built-in commands, or the lack of sensible flags/options for those commands which do exist. You're often falling back to legacy cmd.exe-era executable utils, or invoking some .NET API, both of which result in more verbose, awkward code. e.g. reading/writing the registry is SUCH A PAIN with powershell builtins (why?!?!?), so reg.exe it is. Much of that comes from Powershell's relative youth (the set of builtins and their flags is still evolving), and the relative script-unfriendliness of Windows as an OS compared to unix. So for a particular action, in unix you have have a utility (or even N utilities) with 15 arguments to handle 95% of possible cases, in Powershell you'll get a cmdlet with maybe 5 or 6 arguments that handles 75% of cases, but the output is an object so the remaining 25% can be done by calling some method or grabbing a field. Both approaches have their strengths and drawbacks. The Powershell approach tends to scale better, I'd say - you can create fairly large scripts/packages in pure Powershell without needing to bail out to Python or C#.