Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

As a Linux user, I've always just used bash because it was the default on every distro I used. People using other Unix systems such as BSD seem to use other shells far more frequently. In the interests of learning a bit more, I've decided to try out zsh.

As a bash user:

  • What features will I miss?
  • And what ones should I look out for?
share|improve this question
11  
3  
@Gilles someday it might be nice to have all those moved here... and merged –  xenoterracide Aug 22 '10 at 8:22
add comment

4 Answers

up vote 27 down vote accepted

There's already been quite a bit of activity on the topic on other Stack Exchange sites. My experience of switching from bash to zsh, as far as can remember (it was years ago²), is that I didn't miss a single thing. I gained a lot; here are what I think are the simple zsh-specific features that I use most:

  • The zsh feature I most miss when I occasionally use bash is autocd: in zsh, executing a directory means changing to it, provided you turn on the autocd option.⁴

  • Another very useful feature is the fancy globbing. The hieroglyphscharacters are a bit hard to remember but extremely convenient (as in, it's often faster to look them up than to write the equivalent find command). A few of the simpler examples:
        foo*~*.bak = all matches for foo* except those matching *.bak
        foo*(.) = only regular files matching foo*
        foo*(/) = only directories matching foo*
        foo*(-@) = only dangling symbolic links matching foo*
        foo*(om[1,10]) = the 10 most recent files matching foo*
        foo*(Lm+1) = only files of size > 1MB
        dir/**/foo* = foo* in the directory dir and all its subdirectories, recursively⁴

  • For fancy renames, the zmv builtin can be handy. For example, to copy every file to name.bak: zmv -C '(*)(.)' '$1.bak'

  • Both bash and zsh have a decent completion system that needs to be turned on explicitly (. /etc/bash_completion or autoload -U compinit; compinit). Zsh is much more configurable and generally fancier.

If you run zsh without a .zshrc, it starts an interactive menu that lets you choose configuration options. (Some distributions may disable this; in that case, run autoload zsh-newuser-install; zsh-newuser-install.) I recommend enabling the recommended history options, turning on (“new-style”) completion, and turning on the “common shell options” except beep. Later, configure more options as you discover them.

²At the time programmable completion was zsh's killer feature, but bash acquired it soon after.
Features that bash aquired only in version 4 (so are still not available on many systems) are in smaller type.

share|improve this answer
2  
Bash 4.0 now supports the autocd feature you discuss above. Enable the feature using the command shopt -s autocd. Then the feature works as you've described. –  Philluminati Dec 17 '12 at 1:28
add comment

zsh lets you edit a multi-line command (see zsh line editor), bash doesn't. If you try the same trick (Ctrl-p), bash fetches the last command.

share|improve this answer
1  
Bash does this, at least as of version 4.2.37; it replaces newlines by semicolons and gives you a single line to edit. –  Keith Thompson Jan 24 at 23:57
add comment

Also the default tab completion is better than bash... for example...

~/.e.dTAB will expand to ~/.emacs.d/ in zsh, bash will just beep.

share|improve this answer
add comment

Bash has the feature of being able to open ports using

/dev/tcp/host/port

or

/dev/udp/host/port

However, it is disabled in Debian as it is seen as a hindrance (if the path actually exists) and outside the scope of what a shell should do. More information [debian mailing list]

share|improve this answer
1  
zsh has the ztcp builtin though which has more capabilities than bash's /dev/tcp, doesn't have /dev/udp. I would rather use socat though. –  Stephane Chazelas Sep 10 '12 at 13:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.