Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Worth switching to zsh for casual use? [closed]

Tags:

bash

shell

zsh

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?

like image 355
Will Robertson Avatar asked Sep 04 '08 08:09

Will Robertson


People also ask

Is it worth switching to zsh?

Going back to the power aspect, zsh also offers a LOT more shell built-ins and variable manipulation features. Seriously, zsh's variable manipulation capability is insane. Whether it's worth the switch, this is up to you. I personally switched because I was bumping against the limits of what bash could do.

Why should you use zsh?

Zsh is known for its extensibility, good customization, and advanced features. Since Zsh is made from Bash, almost 90% of the scripting is similar, and it is compatible with Bash. Both Zsh and Bash have many similarities and are easily portable. Many systems started using Zsh as their default shell.

What is Z shell used for?

“Z shell” or zsh for short, was created in 1990 by Paul Falstad. It is also a Unix shell and command language based on Bourne shell with a large number of improvements, including some features of bash. Zsh also had the ability to be used as a scripting language with the ability to use shell scripts.


2 Answers

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 use suffix aliases to associate specific progs with different suffixes, so that you can "execute" them directly. The below alias lets you "run" a C source file at the prompt by simply typing ./my_program.c – which will work exactly as if you typed vim ./my_program.c. (Sort of the equivalent to double clicking on the icon of a file.)

  • 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!

like image 137
Matt Avatar answered Sep 21 '22 17:09

Matt


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.

like image 44
Rodney Amato Avatar answered Sep 19 '22 17:09

Rodney Amato