Live data from Hacker News

Fish shell 3.0

github.com

221–227 of 227 posts

Re: Fish shell 3.0

#221

Earlier quoted context omitted.

What does someone want if they write "bar = print foo,"? Is it the same if "print" isn't the built-in function?

Operator precedence isn't really a new concept, and Python relies on it in plenty other situations: bar = 1 + 1 I do believe Python made the right call, actually: print needed to be unified with functions, and dropping the requirement for parenthesis for function calls would have introduced so much incompatibility as to make the Python 2 -> 3 transition far more difficult. But ignoring the legacy issue, there is a be…

What does operator precedence have to do with this? Ending a parameter list with a comma changes the output of the print keyword but not a function. Assignment statements can contain function calls but not the print keyword.

C style function calls are common, explicit, and consistent. Python adds the best combination of positional, variadic, and named parameters of any language I know. ML style has less punctuation and simpler grouping rules. Ruby has the weaknesses of both.

Re: Fish shell 3.0

#222
post #190

Earlier quoted context omitted.

You don’t. ;-) Use fish/zsh interactively, sh for simple scripts, Python for the more complex.

Yeah I get that. But this method doesn't help for scripts that need to modify the current session state (such as export session variables). I am guessing here that such scripts are an edge case and most shell scripts can be simply executed with sh.

Most scripts are run, not sourced. Some tools support fish. bass[1] aims to handle the rest.

[1] https://github.com/edc/bass

Re: Fish shell 3.0

#223

Earlier quoted context omitted.

That usage doesn't get the weirdly specific error message though. It's only the Python2-ish statement that gets one.

What does someone want "print foo" to do if "print" is a different function? What does someone want "print (1, 2)" to do if "print" is the built-in function? It prints a tuple in Python 2 and ints in Python 3.

I get that. So the Python 3 interpreter has to assume that when I say "print (1, 2)", I actually mean, print these two individual arguments.

If I say "print 'foo'" though, it recommends "print ('foo')", but doesn't go all the way to assume I actually meant that. There's a piece of code handling that special case that stops short of actually interpreting what I apparently mean.

The frustration around that was the original point.

Re: Fish shell 3.0

#224
post #44

Earlier quoted context omitted.

Finally! Fish 2.x shows you a message along the lines of "use `and` instead of `&&`", which is infuriating - it clearly knows what I want to do, and refuses to do it. I love fish and use it as my default shell, but I'm glad to see the fish team take a few steps towards bash compat.

That reminds me of the very specific nag messages I get from Python 3 when I don't write parens around parameters for print... do what I want already.

If print() is a function why should you be able to call it like that?

Python 3 was just fixing that inconsistency. Functions have their arguments inside of parentheses.

Should we be able to call "requests.post url, data"? It sounds like you are upset with the language for resolving something that never made sense to begin with.

Re: Fish shell 3.0

#225
post #148

Can anyone who's experienced with both fish and zsh comment on reasons fish might be better?

Shell scripting finally feels sane. Just the normal "if" and other basic conditionals make you feel you want to switch. Some scripting example : https://nicolas-van.github.io/programming-with-fish-shell (I use zsh as shell, as enough customization can do much of what fish can achieve with bit more stability but maybe they fixed with 3.0 which I haven't tried yet.)

This is nice and everything, but I don't see why you would write fish scripts in the first place. For anything like that I'd use python, and imo the only reason to do POSIX shell scripting is that a compliant shell is probably preinstalled on your target platform.

Re: Fish shell 3.0

#226

My favorite feature of fish is `abbr`, e.g. `fish abbr --add g git`. Then you type `g` followed by space and it just expands it to `g` and you then get all the autocomplete goodness and don't have to futz with adding autocomplete support to an alias, because it is the real command. It also helps for presentations because instead of some obscurely named alias, you can type an abbreviation and it just expands it out fo…

Nice, thank you. I have been using fish for a long time, but wasn't aware of these.

Have defined the following:

  abbr -a gp 'git push' 
  abbr -a k kubectl
  abbr -a n 'npm run'
  abbr -a y yarn
  abbr -a m make

Now, when I type n, then SPACE, then TAB, I can get the list of npm tasks for example.

Re: Fish shell 3.0

#227
post #174

Earlier quoted context omitted.

Ah, timing other shell functions is a use case I hadn't considered. Yes, then you're out of luck I suppose.

I think $duration is a thing, which is the time it took to run the previous command. It doesn't separate things like time does, but it's still useful for some cases. In fact, I customized my prompt to pretty print the previous command's duration if it took longer than 3 seconds or something like that.

I use the Spacefish prompt plugin[0], which does that as well, and comes with a whole lot of other goodness!

[0] https://github.com/matchai/spacefish

Post reply on HN