News for hackers. Stuff that matters.
Re:Fish Shell 3.5.0 by nikivi on Thursday June 16, 2022 @01:14PM (#31768534)
Been meaning to move fully to Fish, was just dreading the amount of zsh functions I'd have to rewrite.

Is there any reason to use Zsh at this point over Fish?

Re:Fish Shell 3.5.0 by medler on Thursday June 16, 2022 @01:36PM (#31768772)
I used fish for a long time, but lost patience with the incompatibility with other shells. It’s nice to be able to just paste and run someone else’s command, and I eventually tired of having to rewrite every command to use fish syntax. For example, replacing FOO= with set - x … The reverse is even worse—if I need to send someone a command to run, I have to rewrite it in a syntax that’s likely to work when they run it. It only takes a few seconds each time but I grew weary of it.
Re:Fish Shell 3.5.0 by mixmastamyk on Thursday June 16, 2022 @01:40PM (#31768810)
That’s accepted now, and was always available by prepending env.
Re:Fish Shell 3.5.0 by ilaksh on Thursday June 16, 2022 @06:01PM (#31771539)
They have improved compatibility a lot.

Also, you could do what I do: leave bash or something else as the default, and then just run fish manually.

Then if I have a problem pasting or something I run type exit.

But the incompatibilities are a lot less now.

Re:Fish Shell 3.5.0 by Starlevel001 on Thursday June 16, 2022 @02:23PM (#31769278)
You can just do `bash -c "CMD"`.
Re:Fish Shell 3.5.0 by tomjakubowski on Thursday June 16, 2022 @02:27PM (#31769321)
occasionally you'll need to run a command which sources or exports… it's no silver bullet in my experience anyway
Re:Fish Shell 3.5.0 by pxc on Thursday June 16, 2022 @11:54PM (#31773950)
Check out fish-foreign-env, bass, and babelfish
Re:Fish Shell 3.5.0 by ducktective on Thursday June 16, 2022 @02:33PM (#31769392)
create a key-binding to invoke your terminal with bash. I have not set fish as my system shell (aka chsh)
Re:Fish Shell 3.5.0 by cmer on Thursday June 16, 2022 @01:17PM (#31768560)
I was in a similar situation 2 years ago and I took the plunge. Turns out, the amount I had to rewrite was fairly minimal, and the benefits of Fish are just incredible. I'd say: go for it, you won't regret it!
Re:Fish Shell 3.5.0 by CJefferson on Thursday June 16, 2022 @01:38PM (#31768794)
Personally, I'm a lover of subshells, I often write things like (cd mydir && make), making use of the fact the 'cd mydir' only happens in the subshell.

Fish doesn't have anything like that, there are a few workaround, but none of them are (in my opinion) anywhere near as nice.

Re:Fish Shell 3.5.0 by lytedev on Thursday June 16, 2022 @08:15PM (#31772580)
You should instead

    pushd /my/path && command && popd
Both in bash AND in fish!
Re:Fish Shell 3.5.0 by CJefferson on Friday June 17, 2022 @02:31AM (#31774752)
the problem with that is I ended up in the wrong directory if I press ctrl+c, or in the exact examples you give, if command fails.
Re:Fish Shell 3.5.0 by onei on Thursday June 16, 2022 @02:16PM (#31769215)
If it's just make you're doing that for "make -C mydir" does that and puts you back in the original directory when it's done.
Re:Fish Shell 3.5.0 by tomjakubowski on Thursday June 16, 2022 @02:21PM (#31769256)
I do this too (in zsh), but maybe writing a function callable like this would work:

  with mydir make
Although you'd want to be able to write things like

  with mydir make && ./bin/myprog
and parse everything to the right of `mydir' as a shell pipeline. That might be the sticking point in fish.
Re:Fish Shell 3.5.0 by 8ytecoder on Thursday June 16, 2022 @02:02PM (#31769097)
I use this a lot in my scripts - handy when you want to capture the output or execute a command in a different directory.
Re:Fish Shell 3.5.0 by lytedev on Thursday June 16, 2022 @08:17PM (#31772592)

    set output (echo captured)
    echo $output
    > captured
And if you wanna run a command in another dir:

    pushd other_dir
    run_command
    popd
Re:Fish Shell 3.5.0 by tomjakubowski on Thursday June 16, 2022 @02:25PM (#31769304)
zsh has survived for longer (it's "Lindy") and is therefore more widely available on remote machines. Also, maybe just my problem, but I do get frustrated having to switch back to bash/zsh syntax and semantics in cases where Fish isn't available, or when writing scripts others will use. Easier for me to stick with zsh for my shell and bash for shipping shell scripts.
Re:Fish Shell 3.5.0 by smoldesu on Thursday June 16, 2022 @01:17PM (#31768564)
zsh tends to actually run scripts when you feed them. As long as you can resist the urge to run all of your POSIX scripts in fish, I think I much prefer fish as an interactive shell.
Re:Fish Shell 3.5.0 by cmer on Thursday June 16, 2022 @01:22PM (#31768608)
Exactly. Falling back to Bash to run scripts makes life easier. Just add a Bash shebang at the top and you're good to go.
Re:Fish Shell 3.5.0 by agency on Thursday June 16, 2022 @02:19PM (#31769240)
Last time I looked into switching the vim mode in zsh was better by enough of a margin that I didn't switch, but that was years ago. I've been meaning to give fish another shot.
Re:Fish Shell 3.5.0 by axkdev on Thursday June 16, 2022 @04:32PM (#31770638)
You can 1. Make your scripts executable or 2. Use bash / zsh inside of fish. 3. You can define wrapper functions in fish that just call bash/zsh functions internally. I use fish, although I hate writing scripts in it. It just feels wrong. Better stick to good old bash.
Re:Fish Shell 3.5.0 by pxc on Thursday June 16, 2022 @11:57PM (#31773965)
For copying and pasting while preserving environments, you can always use `exec` as an escape hatch.

  exec bash
  <paste some bash>
  exec fish
Re:Fish Shell 3.5.0 by moondev on Thursday June 16, 2022 @01:32PM (#31768734)
process substitution?

fish: Invalid redirection target: yq3 r <(kubectl get nodes -o yaml)

Re:Fish Shell 3.5.0 by Tmpod on Thursday June 16, 2022 @01:51PM (#31768931)
You can do process substitution by piping into the psub command ;)
Re:Fish Shell 3.5.0 by moondev on Thursday June 16, 2022 @01:56PM (#31769011)
juice is not worth the squeeze
Re:Fish Shell 3.5.0 by inyourtenement on Thursday June 16, 2022 @02:58PM (#31769633)
<(blah) vs (blah | psub)