tags:

views:

1665

answers:

6

The default shell in Mac OS X is bash, which I'm generally happy to be using. I just take it for granted. It would be really nice if it auto-completed more stuff, though, and I've heard good things about zsh in this regard. But I don't really have the inclination to spend hours fiddling with settings to improve my command line usage by a tiny amount, since my life on the command line isn't that bad.

(As I understand it, bash can also be configured to auto-complete more cleverly. It's the configuring I'm not all that keen on.)

Will switching to zsh, even in a small number cases, make my life easier? Or is it only a better shell if you put in the time to learn why it's better? (Examples would be nice, too :) )


@Rodney Amato & @Vulcan Eager give two good reasons to respectively stick to bash and switch to zsh. Looks like I'll have to investigate both! Oh well :)

Is there anyone with an opinion from both sides of the argument?

+3  A: 

zsh has a console gui configuration thing. You can set it up pretty quickly and easily without having to fiddle with configuration files. I don't think you will need much time to set it up, probably 10 seconds with just using defaults, so go ahead and try it out.

Staale
+1  A: 

Staale is talking about a wizard like program (CUI) which autoruns the first time you run zsh. Just answer some questions, view/change the defaults and its configured for you.

IBM developerWorks has great resources on zsh.

I have not used very advanced features and so far I have not come across serious differences which should hamper someone coming from bash.

Some examples:

  • !?pattern<Tab> will autocomplete to the last command in history matching pattern. Very useful.

  • You can configure a prompt on the RHS. One use is to keep a fixed width prompt on the left hand side so all commands line up nicely while displaying the pwd (or anything of variable width) as the right hand side prompt.

  • You can redirect input from multiple files (yet to try this): cat < file1 < file2 < file3

Vulcan Eager
+9  A: 

For casual use you are probably better off sticking with bash and just installing bash completion.

Installing it is pretty easy, grab the bash-completion-20060301.tar.gz from http://www.caliban.org/bash/index.shtml#completion and extract it with

tar -xzvf bash-completion-20060301.tar.gz

then copy the bash_completion/bash_completion file to /etc with

sudo cp bash_completion/bash_completion /etc

which will prompt you for your password. You probably will want to make a /etc/bash_completion.d directory for any additional completion scripts (for instance I have the git completion script in there).

Once this is done the last step is to make sure the .bash_profile file in your home directory has

if [ -f /etc/bash_completion ]; then
     . /etc/bash_completion 
fi

in it to load the completion file when you login.

To test it just open a new terminal, and try completing on cvs and it should show you the cvs options in the list of completions.

Rodney Amato
+12  A: 

Personally, I love zsh.

Generally, you probably won't notice the difference between it and bash, until you want to quickly do things like recursive globbing:

  • **/*.c for example.

Or set associate specific progs with different suffixes:

  • alias -s c=vim

Or print the names of files modified today:

  • print *(e:age today now:)

You can probably do all of these things in bash, but my experience with zsh is that if there's something I want to do, I can probably find it in zsh-lovers. I also find the book 'From Bash to Z-Shell' really useful.

Playing with the mind bogglingly large number of options is good fun too!

Matt
+2  A: 

If all you want to use ZSH for is better completion, the configuration is pretty easy. Place this in your ~/.zshrc:

autoload -U zutil
autoload -U compinit
autoload -U complist
compinit

However, it's worth checking out all the other great featuresn of the ZSH. The above example will give you a pretty plain prompt with good completion. If you don't want to fiddle with configurations, but want to see what ZSH can do for you, google for "zshrc" and you will get some ready to use configurations to get started.

jkramer
+1  A: 

Switch to zsh. You will have access to:

  1. zmv. So you can do: zmv '().mp3' '().wma' for thousands of files.
  2. zcalc. Extreamly comfortable calculator, better than bc.
  3. zparseopts. One liner to parse arbitrary complex options given to your script.
  4. autopushd. You can always do popd after cd to get back.
  5. Floating point support. It is needed from time to time.
  6. Hashes support. Sometimes they just key feature.