7 ms·
As a full-time Linux user, I have to say that bash is overrated. For instance, on Windows I could press the up arrow through my history 20x to find a group of
by larrik 10y ago
As a full-time Linux user, I have to say that bash is overrated.
For instance, on Windows I could press the up arrow through my history 20x to find a group of commands I want to run, press Enter, then press DOWN for the following command, then enter, then DOWN until I run them all. In Bash, I need to press UP 20x every single time.
Yes, you can customize it a lot, and you can script it but default bash isn't that special to me.
- soperj 10y agoOr just be sane and use ctrl-r and search.
- feld 10y agoI get the feeling that most users have only accessed 5% of the features available in their unix shell of choice
- emgee3 10y agoI would say not just the shell but most software
- fapjacks 10y agoAnd almost certainly languages, too. For example C++.
- npsimons 10y agoAs someone who has created templated subclasses with both private and public virtual inheritance, I don't think that's a bad thing. C++ is wildly powerful, but it's a mess, and most people should stick to easily understood idioms/patterns, for the sake of maintenance if nothing else.
- nitrogen 10y agoI also highly recommend enabling the pgdn/pgup bindings for history-search-forward/backward. If you are searching for a prefix it's a bit easier than ^R.
- pvdebbe 10y agoI bound these under C-n and C-p. Very convenient indeed!
- larrik 10y agoI do use this too.
- lmm 10y ago> For instance, on Windows I could press the up arrow through my history 20x to find a group of commands I want to run, press Enter, then press DOWN for the following command, then enter, then DOWN until I run them all. In Bash, I need to press UP 20x every single time. I think the Bash default is better here. If I wanted to run 20 closely related commands, I would make them a single line; far more commonly I want one command from 20 commands ago and then the last command, which is a pain to do on Windows. Much worse is that Windows seems to lose all history every time I close and reopen a command window.
- SixSigma 10y agoBash is awful. But so are shells in general. Even Rob Pike says as soon as your shell program gets longer than a few lines, write it in a proper language.
- clebio 10y agoCitation please? I would love to share this with some of my coworkers.
- SixSigma 10y agoI can't find it anywhere, I have tried. I think it is in the plan 9 mailing list - 9fans, as that is where I have interacted with Rob
- satysin 10y agoI feel that principle is true from all high-level languages as you move down the chain. Shell scripts should be 1-20 lines. Python/Ruby/whatever for 20-100 and compiled for anything >100.
- jamespo 10y agoWhat if you use Nuitka or PyPy for Python, does that magically allow you across the arbitrary border?
- mikestew 10y agoI was about to refute you with a recent example of mine that just needed to serially execute a bunch of commands, and it's well over 20 lines. Then I remembered that I needed to introduce some branching logic, said "not in bash, I'm not", and rewrote it in Python. So for me, it's not a matter of LoC but complexity. Need to copy file from here to there, then commit to git repo, blah, blah, blah, then kick off a build? Whether it's a 1000 lines or 2, I don't have a problem with doing that in bash. But as soon as I need some logic (or on rare occasions, perf), I go to something else. Given that, why do you cut shell scripts off at 20 lines? I ask in the spirit of being open to the possibility that maybe I'm doing it wrong. :-)
- Spivak 10y agoIt seems weird that the feature of PS that you're most impressed with is something so... trivial? You have full access to your history in both shells so you could easily emulate that feature in bash/zsh or you could create a special binding to run all commands from a point in your history so you only have to press Enter once.
- larrik 10y agoI actually think the basic windows command line that does it, as I was never in the habit of installing PS while on Windows.
- deleted 10y ago[deleted]
- cstross 10y agoBash is 27 years old. It was written to replace the Bourne shell, which is 39. It is not terribly surprising that a 9 year old tool like Powershell made some improvements over an earlier tool that was already old enough to vote!
- lottin 10y agoThe bash I'm running is actually 3 years old. You make it sound like bash was written 27 ago and no one has touched it since then. Secondly, what constitutes an improvement is a matter of opinion. For example, I don't see this Powersell as an improvement at all.
- ktRolster 10y agoAutocomplete in Bash was actually a revolutionary improvement
- jodrellblank 10y agoAnd autocomplete in PowerShell is again. Cmdlets tell the shell their parameters, and their parameters are long names, so you can just tab through them to find a) the available parameters and b) the ones which might help you.
- Sylos 10y agoWell, it's not an improvement, it's just a different design-choice. I for example much prefer Bash's way of doing it. Also, Bash does have a way of doing it the Powershell-way, if you want that, as others have commented. Which is also why I disagree with your statement. Bash may be old, but neither the underlying technology nor the use-case changed much in that time. So, there is not a whole lot where you can innovate with a new tool, at least not for such basic tasks, and instead, Bash has matured throughout 27 years to perfectly fit that underlying technology and use-case that millions of people have.
- ldiracdelta 10y agoI don't see a tremendous amount of accumulated wisdom in Powershell. It may be newer, but I'm not sure they looked at prior art or had design members who were shell gurus in any other shell than `cmd.exe`, which is a horrific shell. Why are commands horrendously long in powershell? If you spend time in the shell, you don't want your fingers falling off due to overuse. Aside... one of the design decisions Microsoft took that absolutely blows my mind is using `\` for file hierarchies instead of `/` when you're writing an operating system in C!
- pm215 10y agoYou can use control-O for that, which does "execute this command as if I pressed enter, then when it's done bring up the following command in command line prompt". So if you have a set of commands to run that are 20 lines up in history, you can first find them (with 20x UP or by reverse-search), then just control-O control-O control-O control-O ... to execute them one after another.
- petepete 10y agoI wasn't aware of this. Thank you. Not that I've been using Bash and zsh every day for twelve plus years...
- mikestew 10y agoTwelve? Youngster. I'd guess I'm coming up on thirty years. And I did not know this. Now the trick is to remember it next time the need comes up. :-)
- deleted 10y ago[deleted]
- verbify 10y agoSeems to be an instance of Cunningham's Law: https://meta.wikimedia.org/wiki/Cunningham%27s_Law https://meta.wikimedia.org/wiki/Cunningham%27s_Law
- tbrock 10y agoOh. My. God. Life changing! Out of curiosity, how did you discover that you could do this?
- pm215 10y agoIt's been something I've used for many years, so I really don't recall any more just where I found out about it...
- 10y ago
- egwynn 10y agoIn many bash configurations, ctrl-o is bound to 'operate-and-get-next’. If you hit up 20x, you should then be able to hit ctrl-o to run that command, and your history will automatically go to the next command down. Check it out, it’s great! EDIT: beaten by pm215!
- ldiracdelta 10y agoIf you put this in your `~/.inputrc` [1]: "\e[A": history-search-backward "\e[B": history-search-forward "\e[C": forward-char "\e[D": backward-char you can start typing a previous command and go up through your history for all commands starting with whatever you currently have typed into the bash shell. Reset the scrolling through the history with `ctrl+c`. Personally, I hate that powershell remembers your position in the shell history. I don't want to maintain a mental model of the shell history rollodex and where I am in it. That's one less part of my brain that I can't use for thinking about the code. If I have a set of commands to type over and over: history 20 | head -10 | sed -r 's/^ *[0-9]+ *//g;' > new_script.bash * [1] http://codeinthehole.com/writing/the-most-important-command-line-tip-incremental-history-searching-with-inputrc/ http://codeinthehole.com/writing/the-most-important-command-...
- larrik 10y agoI think I tried something like this once before, and it broke something else. I can't remember what that was, so I'm totally trying this.
- larrik 10y agoYeah, this breaks the "move over by word" with Ctrl+Left and Ctrl+Right which I use a lot. Maybe I need to add them explicitly.
- ldiracdelta 10y agoAh. I use the standard emac'esque commands to move over by word. alt+b for back word, alt+f for forward word. Not at all intuitive... windows line movement commands win over emacs bindings form an intuitive perspective. Also you don't need these to get up/down to work: "\e[C": forward-char "\e[D": backward-char Those are for left/right arrows.
- deleted 10y ago[deleted]
- lottin 10y ago
- njkanjsd 10y agoIt's just default behavior and its customizable for a reason. Different people have different preferences, powershell's default behavior is in no way 'better' than bash's. You can also use a different shell like zsh.
- ThatGeoGuy 10y ago>For instance, on Windows I could press the up arrow through my history 20x to find a group of commands I want to run, press Enter, then press DOWN for the following command, then enter, then DOWN until I run them all. In Bash, I need to press UP 20x every single time. I know other users have addressed this issue in other comments with solutions, but you do know this isn't an issue with Bash so much as it is with readline, right? There are plenty of ways to customize readline/inputrc to make it do what you want. There's even linenoise, if you hate readline for what it is. It wouldn't matter how good Bash got as a shell language, this scenario wouldn't be any easier unless readline also gets a facelift.
- larrik 10y agoI actually did not know that.
- JeffreySnover 10y agoFor the record - the PowerShell team loves Bash and much of PowerShell is modelled after it. To be fair - we also modelled portions after VMS DCL, Perl, TCL and AS400 CL. There are lots of awesome engineers out there working on different platforms and we learned a lot from of them. Jeffrey Snover [MSFT]
- atmosx 10y agoYou can use Ctrl+R for reverse search. However, these are minor things... You can find a plugins and what-not to add these kind of functionalities. I use oh-my-zsh and I'm more accustomed with searching sub-history of commands, e.g. nmap <up> #=> shows flags...
- akerro 10y agoI do that same on bash and zsh since... ever?