Live data from Hacker News

Fish 4

github.com

81–90 of 113 posts

Re: Fish 4

#81
post #34
post #6

I've used Fish for many years, but frankly only for the great autocompletion. The streamlined theme/prompt system and oh-my-fish plugin management are quite nice too, but minor. The rest of Fish features that are not bash-compatible are rather a pain, particularly environment variable management. In principle these features have a better design than in bash, but not that much better, and their use is infrequent enoug…

Can I ask what you find difficult about the environment variables system in Fish? Personally I find it absolutely lovely to use.

When you don't use it all the time it's impossible to remember what all the flags are for. The names/scopes are also not helpful, I usually want universal, but think I want global because I don't remember there is a universal. And the thing I have to look up every time is how to set a variable for the current line.

I'm not saying these are hard things, to figure out. I just agree that they're hard to remember when you don't use them all the time.

Re: Fish 4

#82

As a zsh user, I've been meaning to give fish a try. I keep adding plugins to zsh to make it act like fish (like command autocomplete) that I might as well try and/or switch to it.

My only annoyance with fish is when I copy bash one liners and forget, and get errors or issues. Otherwise, fish is fantastic.

There's a nice way to halfway-fix that issue. It makes use of the fact that most bash commands that we copy are prefixed with a $ and a space. It also requires your terminal emulator to have a way to hook into the paste mechanism and edit the to-be-pasted text. To my knowledge, Kitty and iTerm both have this feature.

Basically, the terminal will replace each line of the pasted text that match (start with)

  $ rest
with

  pbash 'rest_escaped'
or more elegantly

  \$ 'rest_escaped'
We will then define a function with either of these names in fish.

This function will start (if not exists) a persistent background bash instance connected on both ends to FIFOs, with the same lifetime as your fish session. We then pass the `rest_escaped` to one FIFO, capture the output from the other FIFO, and echo it.

Because its a persistent session, stuff you copy that makes use of variables or bash aliases all Just Work. Being able to blindly copy-paste the entire bash codefence from a github readme.md is especially nice.

It all happens automatically after a one-time setup, and overall works pretty well for me. Here is a demo: https://i.imgur.com/HdqGkRk.png

This is the fish function

  function \$
      if not test -f /tmp/bash_daemon.pid; or not kill -0 (cat /tmp/bash_daemon.pid) 2>/dev/null
          echo "Starting bash daemon..."
          bash ~/scripts/bash_daemon.sh &
          sleep 0.5
      end
  
      echo "$argv" > /tmp/bash_daemon_pipe &
  
      while read -l line
          if test "$line" = "###DONE###"
              break
          end
  
          echo $line
      end 
And this is the bash script `~/scripts/bash_daemon.sh`

  #! /usr/bin/env bash
  
  rm -f /tmp/bash_daemon_pipe /tmp/bash_daemon_out
  mkfifo /tmp/bash_daemon_pipe
  mkfifo /tmp/bash_daemon_out
  
  echo $$ > /tmp/bash_daemon.pid
  
  while true; do
      read cmd  /tmp/bash_daemon_out
  done

Re: Fish 4

#83

Earlier quoted context omitted.

I’m not sure I’ve ever heard of a Rust programmer using Darcs. Anyone likely to would use Pijul.

well that's the thing, you never know. certainly if i ever used rust to a serious degree, i'd not stop using darcs. however right now that'd necessitate bypassing the whole package management part of cargo, at least for my own libraries (and i suffer from a terminal case of NIH syndrome) i don't think it's reasonable to assert that my own quirks and tastes are explicitly tended to. and that's why ideally you just giv…

What I mean is that in open source, things only get done by people motivated to do them. Nobody has ever even asked for darcs support: https://github.com/rust-lang/cargo/issues?q=is%3Aissue%20sta...

So the lack of darcs isn’t because the Cargo folks think it’s bad or something. Just that things don’t get added just because.

Re quirks, sure, that’s why rustc and cargo are different. You don’t have to use Cargo. Meta does not, the Linux kernel does not.

Re: Fish 4

#84
post #30

I recently built my own shell to better understand its complexity and how it works under the hood. I also implemented redirections and partial tab completion. While I get that writing a shell isn’t the easiest task, I still don’t fully understand why there are so many different ones. I’ve been using the default shell on macOS, and so far, it works just fine.

I go another notch: Why are so many different ones with so little major changes.

If you experience the `shell` of FoxPro DOS or other tools you will see how poor are the ones we tolerate now. Is like we still live in the age of `ed`.

(I even remember one of this projects have the joke that is finally a `terminal for the 90s!` or something like. Shells in common use a very poor things!)

Re: Fish 4

#85
post #34

Earlier quoted context omitted.

Can I ask what you find difficult about the environment variables system in Fish? Personally I find it absolutely lovely to use.

When you don't use it all the time it's impossible to remember what all the flags are for. The names/scopes are also not helpful, I usually want universal, but think I want global because I don't remember there is a universal. And the thing I have to look up every time is how to set a variable for the current line. I'm not saying these are hard things, to figure out. I just agree that they're hard to remember when yo…

I don't know if this helps at all but you can use `export FOO=bar` in Fish, and the prefixing a line with an envvar should work the same as in Bash etc. like `FOO=bar echo $FOO`

Re: Fish 4

#86

Earlier quoted context omitted.

My only annoyance with fish is when I copy bash one liners and forget, and get errors or issues. Otherwise, fish is fantastic.

There's a nice way to halfway-fix that issue. It makes use of the fact that most bash commands that we copy are prefixed with a $ and a space. It also requires your terminal emulator to have a way to hook into the paste mechanism and edit the to-be-pasted text. To my knowledge, Kitty and iTerm both have this feature. Basically, the terminal will replace each line of the pasted text that match (start with) $ rest with…

Wow! This is fantastic! I will have to set this up ASAP.

Re: Fish 4

#87

> However, there should be no direct impact on users. I find this quite impressive, that they rewrote the whole Fish core, but everything keeps working exactly in the same way (except very few minor things which change in only minor ways, which they list).

I don't feel this is impressive. In Big Tech companies it's common for a team to rewrite an entire microservice without having any impact on users. Sure, a lot of that is for political reasons and unnecessary from a business perspective, and perhaps is selfish from a promotion perspective, but it's done very often.

Re: Fish 4

#88

Earlier quoted context omitted.

well that's the thing, you never know. certainly if i ever used rust to a serious degree, i'd not stop using darcs. however right now that'd necessitate bypassing the whole package management part of cargo, at least for my own libraries (and i suffer from a terminal case of NIH syndrome) i don't think it's reasonable to assert that my own quirks and tastes are explicitly tended to. and that's why ideally you just giv…

What I mean is that in open source, things only get done by people motivated to do them. Nobody has ever even asked for darcs support: https://github.com/rust-lang/cargo/issues?q=is%3Aissue%20sta... So the lack of darcs isn’t because the Cargo folks think it’s bad or something. Just that things don’t get added just because. Re quirks, sure, that’s why rustc and cargo are different. You don’t have to use Cargo. Meta d…

sure sure, and what i mean is that ideally the package manager can be made to use any arbitrary vcs system by the programmer. that's all. early on choices were made with cargo's development to where it's non-trivial to make something like that work, you touched on that briefly. it's a good example of why making a package manager is hard, there are so many aspects to them and it's really easy to engineer yourself into a corner to where any individual aspect of them might be flawed. typical software problem, expounded by the fact that package managers are deceptively complicated. doubly expounded by what i mention with language package managers not having the "opt-in" inherent quality of system package managers, not in the same way.

ideally it'd just have an interface you can write a module against. maybe they've added that? i sure hope they didn't have to hardcode the options of that new vcs switch ;)

> that’s why rustc and cargo are different

indeed. but rust analyzer really likes you to use cargo. i know it provides facilities for specifying a json in place of cargo.toml, which is great, but my limited experience with that saw me running into some weird issues (maybe they've been fixed, maybe it was just a skill issue.)

also i will say cargo does at least let you specify local paths as dependencies relatively painlessly, so it gets points for that escape hatch.

Re: Fish 4

#89

Earlier quoted context omitted.

Faster than previous C++? Only if there were actual performance bugs that they fixed while doing the port.

What makes you think so? The Rust compiler is able to instrument LLVM a lot better and provide it with a lot more info than C++ can. The borrow checker does a lot of the work there to for example keep things on the stack or do LSE or GSE and other optimizations. It isn't just about "oh, the rewrite allowed them to restructure things and optimize the algos". It is also that Rust due to its nature is able to be absolut…

[deleted]

Re: Fish 4

#90

Earlier quoted context omitted.

What makes you think so? The Rust compiler is able to instrument LLVM a lot better and provide it with a lot more info than C++ can. The borrow checker does a lot of the work there to for example keep things on the stack or do LSE or GSE and other optimizations. It isn't just about "oh, the rewrite allowed them to restructure things and optimize the algos". It is also that Rust due to its nature is able to be absolut…

Additionally, some people shared that they feel more comfortable making more aggressive optimizations in their Rust code because the borrow checker has their back. Stylo was tried twice in C++ before the Rust attempt, and it never worked out, because the threading was too hard to get right. In theory you could have done it. But in theory, theory and practice are the same, but in practice, they’re different.

IIRC, you yourself commented a few years ago in a thread on HN that the Rust situation was still a lot like "because of certain guarantees Rust makes we should be able to perform tons of optimizations that C++ could never do, and we haven't even gotten around to implementing most of them yet", has that situation improved a lot since?

("a few" might be off by pre-pandemic amount of years, my memory is a bit fuzzy there)

Post reply on HN