Live data from Hacker News

The fish shell is amazing

rmpr.xyz

211–220 of 302 posts

Re: The fish shell is amazing

#211

Earlier quoted context omitted.

I moved from bash => zsh => fish. I wanted reasonable features on my shell, and fish was much faster and needed almost no plugins. The fact that I can write a simple for loop without needing to look up how to do it by far beats the POSIX compatibility, if I need it I can still write a bash script, but when using the shell I don't need to recall where semicolons or `do`, brackets (and how many) go.

Is it that hard to remember a bash for loop? for i in $(seq 1 10) do echo $i done Then you can just replace new lines with ; if writing a one liner. for i in $(seq 1 10); do echo $i; done I guess it isn't as simple as python for i in range(10): print(i) but it's pretty close aside from the variable binding.

In zsh you can avoid the do if you have a single instruction:

    for i in {1..10}; echo $i
to me is as clear as the python version. Very compact and useful for one liners.

Re: The fish shell is amazing

#212
post #128

Earlier quoted context omitted.

>I’m still frustrated by weird posix incompatibility. Can you also share what are the most significant problems with posix incompatibility for you? Why is it a problem?

The one I see is really, all of Linux vs OSX/MacOS. And which version of Bash is shipped by default. Internally we have a boot strap run book developers/operations to bring up either Windows/WSL or MacOS to a consistent shell env.

This shouldn't be an issue! Shell scripts begin with e.g.

    #!/usr/bin/env bash
which means the interactive environment is irrelevant. Users of nonstandard shells like fish need to learn a bit of on-the-fly translation if they expect to copy/paste into their terminals, but it isn't too onerous.

Re: The fish shell is amazing

#213
post #7

I used fish for a couple of years and really liked it. But I recently learned that I can configure ZSH to have all of the same auto-complete and plugins that I loved from fish. Now I have all of the creature comforts I like, with POSIX compliance I found that while fish has better syntax than bash for most things, the hassles with incompatibility or unexpected behavior brought me much more trouble than BASH's syntax…

I don't get why people expect POSIX compliance from fish. Your interactive shell and your scripting shell can be, should be, and often are, different. I use bash as my default user shell, fish as the default shell of my terminal emulator, and I write scripts for both POSIX sh (dash and busybox ash) and bash. I end up using three different shells with different purposes. Sure, I could use zsh both as an interactive an…

Then you have to learn two languages. And switch from one to another when you need to do some scripting.

I don't write shell scripts a lot, I prefer to write python scripts (that are more maintainable and simple to write). But I write complex commands in the shell a lot, for example I may need to convert a bunch of images from one format to another, just use a for loop with imagemagik directly from the command line, then maybe a regex with sed to rename them, and done. It's not rare that I write commands that are more than 5 lines long.

With all the quirks of POSIX shell scripting languages (well in reality I use zsh that is nicer) they let you hack things together fast, and that makes them powerful.

Re: The fish shell is amazing

#214
post #128

Earlier quoted context omitted.

The one I see is really, all of Linux vs OSX/MacOS. And which version of Bash is shipped by default. Internally we have a boot strap run book developers/operations to bring up either Windows/WSL or MacOS to a consistent shell env.

This shouldn't be an issue! Shell scripts begin with e.g. #!/usr/bin/env bash which means the interactive environment is irrelevant. Users of nonstandard shells like fish need to learn a bit of on-the-fly translation if they expect to copy/paste into their terminals, but it isn't too onerous.

Not going to ping my coworker that deals with this (Happy Thanksgiving), but the version shipped with OSX was several versions behind Linux.

Re: The fish shell is amazing

#215

Earlier quoted context omitted.

> while Fish has some nice out-of-the-box features, they’re all achievable in Zsh with a few lines of plugins. The point of fish is that there is no configuration required. You don't have to learn to configure it, you don't have to be part of "the community" to learn which plugins to use, you'll be able to sit in front of any fish prompt and have it work as expected without having to move dotfiles around.

> The point of fish is that there is no configuration required. I think it would be more accurate to say that the point of fish is that there is no configuration allowed . If you don't like the out of the box configuration, I would say configuration is still required , but it's unfortunately not available . If you happen to like every single decision the developers made, then I admit having no configuration does mean…

> If you don't like the out of the box configuration,

Then either decide to like it -- humans are adaptable, this is possible -- or don't use the thing. Both outcomes are acceptable. A hammer doesn't need to have a configurable grip and head and claw in order to be a good tool.

Re: The fish shell is amazing

#216

Shells and scripting languages are different things. I don't care how good of a scripting language Powershell is, it's painful to use as a shell. I don't care that fish can't run sh scripts, I've never used it on a machine that didn't have sh. Can we stop judging oranges for their lack of crunch?

Because for you these are two distinct phases. But how many times you use a for loop for launching the same command multiple times? How many time you pass the output of the command as a parameter to another with $(command)? Or you use variable to save things?

Beside very basic usage, a shell is really a REPL for a scripting language. You can type commands but also you can do most advanced things (and that is what makes shell powerful). For example I maybe have to convert all the video files in a directory, and then upload them to a server, I can easily do that with a for loop in the shell, without creating a script.

And since you use both the shell to type commands and to write effectively scripts as in a REPL, that means that you have to learn another completely different programming language, the fish language (of course I assume that you already know POSIX scripting), and not only that, it's probably the case that only on your computer you have fish but it's not installed on every other system, so when you are using another computer (a server, a computer of a coworker that you are helping, etc) you will make mistakes because you confuse the fish syntax with the one of POSIX shell.

Yes, it's true that bash extends POSIX, and zsh too and it's not even compatible 100% with bash, but the differences are in things that it's rare that you will use in a basic script, and all these shells can understand POSIX syntax. A for loop it's the same in sh, bash and zsh (there is a shorter syntax in zsh, but the base one is the same), while it's completely different in fish.

Re: The fish shell is amazing

#217
post #107

Earlier quoted context omitted.

Agreed. I liked fish last time I tried it (probably over a decade ago), but bash scripting is what I'm familiar with and it's just so convenient in day-to-day usage to be able to throw out one-liners for mundane things and then have them permanently searchable in my history.

Have you just tried the following to run your bash one liners in fish? bash -c 'echo "hello"' Replacing echo "hello" with your script.

You could do that, but it would be pretty inconvenient in general, and more so when using quotes within the script. There would also be no autocomplete.

Re: The fish shell is amazing

#218
post #102
post #92

Earlier quoted context omitted.

PowerShell is definitely way more capable a scripting language, but it pales in comparison to Fish when it comes to speed, ease, and pleasantness of interactive use. There's a new generation of shells on the rise which look up to both Fish and PowerShell as models of different virtues they want to embody. A lot of them are already usable, and some day a few of them will be killer apps for developers and sysadmins

Nothing is speedier, easier, or more interactive than Get-Help in Powershell. https://docs.microsoft.com/en-us/powershell/module/microsoft... Using other shells is like living in the stone age. I don't know why people would do that to themselves.

A one liner in bash is an essay in powershell

Re: The fish shell is amazing

#219

Earlier quoted context omitted.

The best reason to choose fish over zsh is that everything works so well out of the box that you stop messing with it. I haven’t tweaked my shell config in 7 or 8 months now. This is a different mindset from the giant zsh configs, “plugin managers” and other junk that is wholly irrelevant to using the shell. You’d think that fish incorporating a lot of functionality that zsh has would manifest as bloating fish, but,…

> The best reason to choose fish over zsh is that everything works so well out of the box that you stop messing with it. This is such an incredibly odd perspective to me. I use zsh and have not touched my shell config in years . Messing with configurations to get things working to your liking is a one time thing. I don't even use plugins. On the other hand, if fish doesn't work to your liking out of the box, and for…

> On the other hand, if fish doesn't work to your liking out of the box, and for many people it does not, there's no "messing with it" that's possible. You are forced to give up and use something else. Your reason to choose fish is only a good reason if you already agree with every minute choice the developers made and refuse to let you adjust.

Which part of fish makes this impossible? You can tweak the startup, the completions, the key bindings, the prompt, and so on.

Re: The fish shell is amazing

#220

Earlier quoted context omitted.

I moved from bash => zsh => fish. I wanted reasonable features on my shell, and fish was much faster and needed almost no plugins. The fact that I can write a simple for loop without needing to look up how to do it by far beats the POSIX compatibility, if I need it I can still write a bash script, but when using the shell I don't need to recall where semicolons or `do`, brackets (and how many) go.

Is it that hard to remember a bash for loop? for i in $(seq 1 10) do echo $i done Then you can just replace new lines with ; if writing a one liner. for i in $(seq 1 10); do echo $i; done I guess it isn't as simple as python for i in range(10): print(i) but it's pretty close aside from the variable binding.

Bash has some subtleties around loops that can be frustrating, like the body of your loop _may_ actually be running in a subshell (common when iterating over a file), making it difficult to extract what you want from it.
Post reply on HN