|
|
Subscribe / Log in / New account

Evolution of shells in Linux (developerWorks)

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 5:47 UTC (Thu) by imgx64 (guest, #78590)
Parent article: Evolution of shells in Linux (developerWorks)

> Shells are like editors: Everyone has a favorite and vehemently defends that choice (and tells you why you should switch).

I'm glad this is less true these days; most people just use Bash because it's the default on their distribution and never think about it. I wasted too much time thinking about editors and trying different ones until I settled on Vim. I do not want to repeat that for shells.

Although to be honest, I did contemplate ZSH at one point, and I liked many of its features. The ones that stand out the most are the autocomplete (for example, autocomplete for umount only shows mounted devices), and ZLE (the line editor, I wish Bash/Readline could edit multi-line history as easily).

But then, the good is the enemy of the perfect (apologies to Voltaire), so I decided that Bash is good enough, and that switching and learning all these new features is not worth my time.


to post comments

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 6:47 UTC (Thu) by lindahl (guest, #15266) [Link] (12 responses)

The nice thing about individual nice features is that other people steal them. Automplete great in zsh? Here is that feature in bash:

complete -A hostname ssh ping traceroute mtr

It doesn't seem to have an 'action' for mounted filesystems.

Still, I have to finish by mentioning that you should definitely switch to emacs :-)

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 7:24 UTC (Thu) by wahern (subscriber, #37304) [Link] (5 responses)

When I'm in bash or ksh every third command seems to be pwd. I'll use bash when bash learns RPROMPT. The right-hand prompt is the greatest thing since sliced bread. No approximations, please.

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 8:42 UTC (Thu) by thedevil (guest, #32913) [Link] (2 responses)

You know about PS1 and the magic characters you can use in it, right?

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 9:31 UTC (Thu) by HelloWorld (guest, #56129) [Link] (1 responses)

What part about "right-hand prompt" and "no approximations" did you not understand?

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 18:33 UTC (Thu) by clump (subscriber, #27801) [Link]

What part about "right-hand prompt" and "no approximations" did you not understand?
Not helpful. There are many ways to have the prompt echo the current working directory. One such way is to use a right hand prompt in zsh, there are others as well. No need to attack people for mentioning that.

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 10:26 UTC (Thu) by imgx64 (guest, #78590) [Link]

You could use a newline in PS1 and have the current directory above the prompt. It's not the same as RPROMPT, but I suppose it solves the problem.

But then again, I don't think you'll really "use bash when bash learns RPROMPT", simply because there is no reason to use Bash if you're happy with Zsh[1].

[1] I don't want to start a shell wars thread, but I'm curious if Bash has any advantages over Zsh other than ubiquity and the user being familiar with Readline (has a customized .inputrc for example).

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 14:42 UTC (Thu) by nix (subscriber, #2304) [Link]

Can't use zsh then. It's got several different types of approximate matching. :)

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 14:40 UTC (Thu) by nix (subscriber, #2304) [Link] (5 responses)

I'm reasonably certain that the zsh autocompletion system cannot be emulated by bash to any real degree. It's the single most overdesigned autocompletion system I've ever heard of, knocking the socks off bash and even Emacs. Half of it is written in byte-compiled zsh script, and a description of it occupies half the zsh manual, over 200 pages!

(But it is seriously awesome despite the ridiculous overdesign.)

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 14:50 UTC (Thu) by nye (subscriber, #51576) [Link] (1 responses)

>I'm reasonably certain that the zsh autocompletion system cannot be emulated by bash to any real degree

Can you give an example of the kind of autocompletion that can be done in zsh but not in bash?

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 16:44 UTC (Thu) by nix (subscriber, #2304) [Link]

You can ask for 'fuzzy completion of each element of a directory separately, displaying completion output in one of several types of menu, grouped by type of entry (e.g. option -- automatically determined from --help output -- versus filename versus directory versus USENET group name versus file descriptor number versus a million other things), with the appearance of each type independently changeable, not duplicating autocompletion entries in a single command if and only if the command is rm, doing spelling correction on directories matching this glob but only for this subset of commands' if you like. And that's just one example I happen to be using.

bash has nothing remotely comparable.

It is *crazy* flexible, so flexible that there is an autoloaded 'compinit' function just so that normal mortals stand a chance of configuring its *default* setup. (This is the 'zshcompsys' completion system, btw, not the 'zshcompctl' system, which is akin to bash's, and is obsolete.)

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 15:48 UTC (Thu) by joey (guest, #328) [Link] (1 responses)

The autoloading of completions on demand is the only reason I still use zsh. When I configured bash to load all completions, starting a shell took enough time to be annoying.

Evolution of shells in Linux (developerWorks)

Posted Dec 14, 2011 0:01 UTC (Wed) by tertium (guest, #56169) [Link]

Then you might find this useful: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=467231 (disclaimer: I'm the original reporter). The script still works fine for me, I only added "declare -p bash4 2>/dev/null" when upgraded to bash 4.

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 23:34 UTC (Thu) by nevyn (guest, #33129) [Link]

Can bash do the auto-complete cycling thing that zsh does?

That's probably at least 50% of the reason I still use zsh, the other 90% being that I configured zsh like 16 years ago and am happy to not have to configure bash when "yum install zsh" works instead :).
RPROMPT is nice too though ;).

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 6:56 UTC (Thu) by geuder (subscriber, #62854) [Link] (1 responses)

> The ones that stand out the most are the autocomplete (for example,
> autocomplete for umount only shows mounted devices),

autocomplete behaviour is not really built-in or more exactly the built-in default behaviour is not suitable for many commands, e.g. umount. Bash does offer an API for everybody (i. e. every command) to get customized autocomplete behaviour.

I have always wondered why there are so many commands that do not install suitable autocompletion scripts for bash. But hey, it's open source. Maybe we should comment less and code more... Contributing those scripts might be more laborous than writing them, though. They don't just belong to bash but you have to work with every command's upstream.

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 14:43 UTC (Thu) by nix (subscriber, #2304) [Link]

Or just contribute them to the bash-completion project's contrib directory. It installs autocompletion scripts for a lot of unrelated projects already...

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 8:28 UTC (Thu) by rvfh (guest, #31018) [Link]

> for example, autocomplete for umount only shows mounted devices

Ubuntu does that for me :-) Just checked on 10.04 at work.

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 10:13 UTC (Thu) by fb (guest, #53265) [Link]

For some reason, I could never get over bash.

At multiple moments in the 90s and early 00s, I got so annoyed with tcsh (or the lack of it pre-installed in many places where I had no su-powers) that I tried to switch to bash. Every time I got so annoyed that I remained with tcsh as my main shell.

IIRC bash had hard limitations at what I could do in a prompt (short of running an embedded command), and at the time it had no completion.

After learning about ZSH, I lived happy ever after. (Note that I learned about it from a friend talking about a shell at which I could play Tetris.)

But you are right about 'good enough', there is a time in life where you can afford to be playing around with different shells, editors etc; later the cost and benefit of migration just don't make sense.

[...]

FWIW, ZSH 4.3.13 was released yesterday.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds