Live data from Hacker News

How zsh is more useful than bash

slideshare.net

51–60 of 151 posts

Re: How zsh is more useful than bash

#51
post #48

I've been using zsh for a while now, mostly without using any special feature that isn't available (maybe with some tweaks) in bash. The additional value for me is that I get all of this out of the box, or with not much effort. That's to oh-my-zsh I've got a nice looking theme (agnoster). Thanks to "zsh-syntax-highlighting" I get syntax highlighting, thanks to "history-substring-search" i got a nice way to search in…

I have yet to find a useful feature that I don't already get in bash (assuming you are capable of sudo apt-get install bash-completion).

Fish (that I don't use regularly), however, has useful features.

Re: How zsh is more useful than bash

#52
Path expansion, can easily be fixed with something like this in bash: CDPATH=".:..:~:~/Desktop:~/Documents:~/Documents/Prj:~/bin:/usr/local:/usr/local/share:/opt/local"

     for realm in ~/Library/Caches/temporaryitems ~/* ~/Desktop/* ~/Documents/* ~/Documents/Prj/* ~/Library/* ~/Library/Scripts/* ~/Library/
     do
         for folder in $realm
         do
                 if [ -d ${folder} ] 
                 then 
    *             CDPATH="$CDPATH":"$folder"
                 fi
         done
     done
As for completions of git and such, that relies totally upon where you got your completion from. There gotta be better arguments than this, and I am really sure there is.

I am on Mac OsX, and I downloaded and installed bash 4.2, and I have never experienced any problems with that.

Re: How zsh is more useful than bash

#53
post #2

I like process substitution feature in zsh. In bash you can write: vimdiff And this will create two pipes, where output of each ls will go. Unfortunately, vimdiff sometimes needs to do second pass on the files, so this command won't work properly when outputs are large. But in zsh you can write vimdiff =(ls /bin) =(ls /usr/bin) and this will create temporary normal files, instead of just pipes, and vimdiff will work…

That seems like a good reason for switching to zsh!

Re: How zsh is more useful than bash

#54

Bah! Give me Ksh.

I much prefer ksh myself, in particular for scripting. Fun fact about how bash is broken: export a=0 cat $file | while read line do a=$(expr $a + 1) done Bash will fork the while loop as a separate process, inheriting (copying) its own environment, and the variable will only update locally, not in the parent process.

I thought every shell that is sh compatible would fork a while, and a for loop, as a matter of fact any loop into a sepearate process.

This comment however reminds me of some behaviour of bash 2.03 or earlier, where this behaviour was flawed, if you suddenly changed execution path during a recursion in a shell script. Sorry I can't describe it better, and that bash version, that was before 2.03 is long gone now!

Re: How zsh is more useful than bash

#55
post #54

Earlier quoted context omitted.

I much prefer ksh myself, in particular for scripting. Fun fact about how bash is broken: export a=0 cat $file | while read line do a=$(expr $a + 1) done Bash will fork the while loop as a separate process, inheriting (copying) its own environment, and the variable will only update locally, not in the parent process.

I thought every shell that is sh compatible would fork a while, and a for loop, as a matter of fact any loop into a sepearate process. This comment however reminds me of some behaviour of bash 2.03 or earlier, where this behaviour was flawed, if you suddenly changed execution path during a recursion in a shell script. Sorry I can't describe it better, and that bash version, that was before 2.03 is long gone now!

Isn't the issue the pipe, not while?

  export a=0
  while read line ; do
    a=$(expr $a + 1)
  done 
(Some old shells fork on < but bash isn't one of them).

Re: How zsh is more useful than bash

#56

Does zsh have bash's ESC+.?

Yes. Not only that but it has something even cooler: ESC + Q

Let's say you are about to finish a really long command and realize you should have done one other command first.

ESC + Q clears the current line, lets you enter a command, and then inserts the cleared line again on the next prompt. You have to try it to realize how cool it is.

Re: How zsh is more useful than bash

#57
post #56

Does zsh have bash's ESC+.?

Yes. Not only that but it has something even cooler: ESC + Q Let's say you are about to finish a really long command and realize you should have done one other command first. ESC + Q clears the current line, lets you enter a command, and then inserts the cleared line again on the next prompt. You have to try it to realize how cool it is.

> Yes. Not only that but it has something even cooler: ESC + Q

ESC+. does not work for me with zsh.

zsh 4.3.11 (i386-apple-darwin12.0)

Maybe it's the version.

ESC+Q also doesn't clear the line.

At the same time, the OP links slide deck fails for me at the cd /u/lo/b part. It simply doesn't work.

Re: How zsh is more useful than bash

#58

I see your zsh and I raise you fish: http://ridiculousfish.com/shell/ Try it. It's better.

i just tried fish. out of the box experience is great. not digging much yet but so far, so good. much faster start up time than zsh. this is 2013 already and i seriously dont' want a shell takes up a second or 2 to fire up.

Re: How zsh is more useful than bash

#59
post #55
post #54

Earlier quoted context omitted.

I thought every shell that is sh compatible would fork a while, and a for loop, as a matter of fact any loop into a sepearate process. This comment however reminds me of some behaviour of bash 2.03 or earlier, where this behaviour was flawed, if you suddenly changed execution path during a recursion in a shell script. Sorry I can't describe it better, and that bash version, that was before 2.03 is long gone now!

Isn't the issue the pipe, not while? export a=0 while read line ; do a=$(expr $a + 1) done (Some old shells fork on < but bash isn't one of them).

I think the pipe was the issue.

Nice to know that bash doesn't fork loops that are being used with redirection, and not piping!

Re: How zsh is more useful than bash

#60

I see your zsh and I raise you fish: http://ridiculousfish.com/shell/ Try it. It's better.

I use fish. It's pretty fun to use. It has some pain points (most notably missing things like subshells and inline variable exporting) but it's in beta, so we'll see where it goes. I love the completions though, and it's definitely worth checking out for those alone.

The subshell syntax is there, it just looks different. Instead of: echo `mycmd`. It's echo (mycmd).
Post reply on HN