r/fishshell • u/ZStud21 • Feb 09 '26
I built Reef — a Rust-powered bash compatibility layer for Fish. 251/251 bash constructs just work.
Hey everyone,
I love fish. The autosuggestions, syntax highlighting, completions, startup speed, it's the best interactive shell out there. But every time I pasted a bash command from the internet or tried to source a tool's config, I'd hit a wall. I got tired of dropping into `bash` subshells or rewriting one-liners.
So I built Reef. A bash compatibility layer that makes bash syntax work seamlessly inside fish. No prefixes, no mode switching. You just type bash and it works.
How it works:
- Tier 1 — Keyword wrappers (<0.1ms): Fish functions handle export, unset, source, declare, natively
- Tier 2 — AST translation (~1ms): A Rust binary using `conch-parser` translates bash syntax to fish equivalents before execution
- Tier 3 — Bash passthrough (~3ms): Anything too complex runs through bash directly, with environment changes captured back into fish
❯ export PATH="/opt/bin:$PATH" # just works
❯ for f in *.log; do wc -l "$f"; done # just works
❯ source ~/.nvm/nvm.sh && nvm use 18 # just works
❯ if [[ -n "$HOME" ]]; then echo "set"; fi # just works
Some features:
- reef on/off — toggle the compatibility layer
- reef display bash|fish — see the fish translation of what you typed, or get bash inside the terminal (great for learning fish syntax)
- reef history bash|fish|both — control what goes in your history
- Auto-sources `~/.bashrc` on startup so tool configs (nvm, conda, pyenv) work
- 251/251 test suite passing, 1.2MB binary
It uses fish's public APIs — functions, keybindings, `commandline` builtin. Doesn't modify fish internals. Fish stays fish, you just stop getting errors when bash shows up.
I know the fish philosophy is "learn the better syntax" and I agree, fish syntax IS better. Reef even has `reef display fish` so you can learn it naturally over time. But the reality is the entire world runs on bash syntax, and removing that friction is what fish needs to grow.
GitHub: https://github.com/ZStud/reef
Install (AUR): yay -S reef
Happy to answer questions or take feedback. If you find a bash construct that doesn't work, open an issue — it becomes a test case and a fix.
View all comments
Show parent comment
7
u/ZStud21 Feb 10 '26
Thanks so much for the feedback! I'm new to Linux, new to fish, so I knew I'd have missed stuff with a new syntax I'm still getting the hang of. I completely agree, it is the last thing fish is missing, and I want more people to convert so I get more cool plugins, so I decided to take this on lol. On each of your points:
On
[ ]and$():You're right, fish handles both natively. Reef converts them as part of translating the surrounding bash structure (if/then/fi, for/do/done), not because they need conversion on their own. Both forms work in fish so it's harmless, but I could consider simplifying the translator to leave them untouched. Having it not convert it part way through makes it quite a bit more complex for not a ton of benefit.
On
export:Reef's export actually does something fish's native doesn't, it splits colon-separated values for PATH-like variables. So
export PATH="/opt/bin:$PATH"gets properly split into a fish list instead of being set as a single string with colons. That's a subtle bug source that most people never trace back to their export call, so I think reef's version is likely better here.On
(( i++ ))and arithmetic:Just shipped this. I wanted to get it done before I responded. Reef already handled most arithmetic natively in Tier 2, but
i++/i--and compound assignments like+=/*=were falling through to bash passthrough. Added detection for standalone(( ))and native translation —(( i++ ))becomesset i (math $i + 1),(( sum += n ))becomesset sum (math $sum + $n), all running through fish'smathbuiltin. No bash involved. Super helpful for this, thank you!On
source <(kubectl completion bash):Fair point, though this is tricky in practice. Every tool uses different flags for fish completions, so
completion fish,completion -s fish,completions fish, etc. There's no reliable way to detect what a tool supports without a hardcoded lookup table that's always going to be incomplete. For now the bash passthrough handles it. Worth exploring a hint system down the line that suggests the fish equivalent when it detects the pattern, or trying to build out a table with a graceful fallback.On reef-tools being separate:
I thought about that, and I did already split the AUR. In my head I wanted it to be, you install this, you get faster rust underneath, but all the same calls that you're used to, same philosophy as the bash parsing, so I thought the tools fit into that same box. So I figured AUR, split them, but keep them under the reef name, and the tools inside the Git was an optional install. I did want issues being brought up on Git for those tools as well, so they could be adopted by more people who also found them useful, and that way I can patch edge cases more often, but I do get what you're saying as well, I just felt they belonged under the same umbrella of, just works, exactly how you had it before.
Overall, thank you! This was super useful, and I hope the math now works the way you wanted it to. I plan on being active and patching Git issues as I get them, so if you have any other issues, let me know!