News for hackers. Stuff that matters.
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