Live data from Hacker News

Use Zsh

fendrich.se

11–20 of 117 posts

Re: Use Zsh

#11
post #7

Earlier quoted context omitted.

Me. Just came to tell, that it's even better than zsh, but ultimately it's a matter of preference.

What are your top reasons to use fish over zsh? (Bearing in mind, of course, that it's ultimately a matter of preference...)

Syntax. I much prefer the fish syntax, even though the fact that it's different from bash can occasionally cause headaches. When I'm mucking with my shell, I'd rather not be remembering [[ -z ]], because I don't do it often.

Basically most shells are designed around power, which is fine. Fish is designed around ease-of-use, which I consider to be a better idea since there's already a ton of power in the UNIX tools that are on the system. That's not to say fish isn't powerful, mind you. Just that you detect a different emphasis when using it.

Consider setting colors in a prompt, for example. zsh and bash use PS1=$'\e[0;31m$ \e[0m'. Ouch. More recent versions of zsh do let you do PS1="%{$fg[red]%}%n" type stuff, I'll confess.

For fish, setting up a colored prompt or whatever:

  function fish_prompt -d "Write out the prompt"
    printf '%s%s@%s%s' (set_color brown) (whoami) (hostname|cut -d . -f 1) (set_color normal) 

    # Color writeable dirs green, read-only dirs red 
    printf ' %s%s' (set_color green) (prompt_pwd)

    # Print git branch
    if test -d ".git"
      printf ' %s%s/%s' (set_color normal) (set_color blue) (parse_git_branch)
    end 
    printf '%s> ' (set_color normal)
  end
It's stuff you already know how to do. It's not an environment variable, it's a function. Commands you use normally. Invoking other regular fish functions/commands. Etc etc. It just feels cleaner (to me).

Re: Use Zsh

#12
Just started using Zsh. I never really had any qualms with bash, and so had the mantra if it's not broke don't fix it.

Then I worked with a couple of junior developers and noticed them doing some cool looking things on the terminal.

Suffice to say I've now switched to Zsh and can't see myself going back to bash any time soon. Thanks junior devs :)

Re: Use Zsh

#13
I've been using zsh for over ten years. Since one of my best friends (now a computational physicist) convinced me to try it in college.

Over time I've temporarily switched to others just to make sure I wasn't being stuck in a rut, but I always have come back to zsh. It's a joy to use as a day to day command line interface.

For writing shell scripts, i.e. actual software implemented in shell, I actually prefer bash. In large part because it's more portable, in the sense that any given machine is likely to have bash already installed.

Re: Use Zsh

#15

> In Bash, we often use PgUp to search through the command history. In Zsh you just write part of the command and press Up. This will let you cycle through all command lines that contain what you have written, not just those that begins with it. If you don’t write anything Up works as usual, by cycling through all commands. This is not true, you can do that in Bash too (via .inputrc) http://blog.theliuy.com/2011/inpu…

In bash, I press ctrl-r and then enter part of the command. additional ctrl-r's cycle.

Re: Use Zsh

#16

I used to use zsh but switched back to bash a couple years ago simply because the benefit wasn't worth the trouble. When I first changed back I went to some difficulty to get my PS1 to have color in it. That slowly faded away and now I have a visceral, negative reaction to prompts with that much colorful whizzy fu. Maybe in a few more years I'll trim out the username/hostname/path and become content with just a %.

It faded away because it was too difficult to get the prompt working?

Re: Use Zsh

#17

I used to use zsh but switched back to bash a couple years ago simply because the benefit wasn't worth the trouble. When I first changed back I went to some difficulty to get my PS1 to have color in it. That slowly faded away and now I have a visceral, negative reaction to prompts with that much colorful whizzy fu. Maybe in a few more years I'll trim out the username/hostname/path and become content with just a %.

It faded away because it was too difficult to get the prompt working?

When you have access to a lot of machines run by different organizations but not administration privileges on most of them, it's a hassle.

Re: Use Zsh

#18

Earlier quoted context omitted.

What are your top reasons to use fish over zsh? (Bearing in mind, of course, that it's ultimately a matter of preference...)

Syntax. I much prefer the fish syntax, even though the fact that it's different from bash can occasionally cause headaches. When I'm mucking with my shell, I'd rather not be remembering [[ -z ]], because I don't do it often. Basically most shells are designed around power, which is fine. Fish is designed around ease-of-use, which I consider to be a better idea since there's already a ton of power in the UNIX tools th…

Ah, so a lot of it is that you like the config language better! That would not have occurred to me. Thank you for your reply.

Re: Use Zsh

#19
post #10

No, really. Use what you like/know. I hate posts about "you should use X because I like it".

How do you ever learn anything or improve your workflow if you never try new things?

Re: Use Zsh

#20
As someone who used zsh for a while but got tired of setting it up everywhere I go and losing the "local community" bash stuff, I humbly request:

someone please post a rebuttal showing how to do all this in bash with appropriate .bashrc/functions and utility programs like fasd.

Post reply on HN