Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.





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

./script.sh

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

I'm simple


If I use fish, I want to make use of it, and that means I will want to convert scripts, or simply learn to write scripts compatible with fish.

Shell scripts from third parties stick with whatever shell they were written for (ie. /bin/sh or /usr/bin/env bash), and commands copy/pasted from the internet are either quickly executed with bash (one-off) or ported over. Because I like to have such in my history (fish is configured to use atuin), I want to keep using the same shell, so I try to stick with fish. If I cannot convert a command (usually a bunch of commands) to fish, it is PEBCAK and a learning curve/experience.

As for tmux, that is solid advice, because it also allows to stick with a shell which is known to work. I've come to like zellij with alacritty, with zellij the option is default_shell. But now that I use ghostty, I don't use a terminal multiplexer locally any more; only remotely. And there I still use tmux.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: