← Back to context

Comment by Fnoord

2 days ago

I've been using fish for nearly 10 years.

First, there are some ways to make fish more compatible with bash.

If you want to do some shell scripting in fish, or running other people's shell scripts (or commands) this may aid you since you wouldn't have to port them (or take less time to port them over).

You can achieve this with a plugin system such as 'oh my fish' or 'fisher'. But, as always, it adds complexity (and bloat :P), you'll need it on every fish shell (including remote systems), etc.

It is a bit akin to having nvim with plugins versus being able to use vi. Sometimes, you're going to need to be able to use the latter.

Also, to people who recently adopted fish: fish has been made more and more compatible with bash throughout those years.

FWIW, I use fish with starship these days.

./script.sh

and script.sh just starts with #/bin/bash

I'm simple

  • This wouldn't work if the script is meant to be sourced (to set environment variables) isn't it?

    • No, it doesn't.

      The way I actually have things setup, in case it helps. I don't change my default shell. I actually default to pretty much working within tmux. So, I kept my default shell to what the OS brings, then in my tmux config, I have,

          # set shell
          set -g default-shell /opt/homebrew/bin/fish
      

      This means, that when I start my terminal, it drops me to zsh (macOS default). Then when I run tmux, it opens fish. The nice thing is that I inherit the environment of zsh.

      I have my .zshrc and my .bashrc sourcing a .shellrc file which contains most of my env stuff. This keeps random utilities that write to .bashrc and zshrc working within fish too.

When I'm in fish and I want to run a bash script I just... call it with bash :-)