LWN.net Logo

Evolution of shells in Linux (developerWorks)

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 6:47 UTC (Thu) by lindahl (subscriber, #15266)
In reply to: Evolution of shells in Linux (developerWorks) by imgx64
Parent article: Evolution of shells in Linux (developerWorks)

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 :-)


(Log in to post comments)

Evolution of shells in Linux (developerWorks)

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

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 (subscriber, #32913) [Link]

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]

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]

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 (guest, #51576) [Link]

>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 (subscriber, #328) [Link]

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 (subscriber, #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 (subscriber, #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 ;).

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