|
Bait is a Bash to fish transpiler. This project is based on mvdan/sh, similar to the existing babelfish project. However, bait translates bash much better, both in quality and supported features. Bait leverages modern fish features to produce clean, idiomatic output. Most common Bash snippets translate with only minimal changes. Bait is experimental, but it can already translate nvm and many prominent installers, allowing them to run natively in fish. |
Screen.Recording.2026-08-30.at.6.26.21.AM.mov |
-
mkdir -p ~/.local/bin && curl --location "https://github.com/kidonng/bait/releases/latest/download/bait_$(uname -s)_$(uname -m).tar.gz" | tar -xz -C ~/.local/bin bait
-
nix profile install github:kidonng/bait
Warning
Bait translation may produce unexpected result. Check output before serious usage.
# Translate from stdin
echo 'VAR=hello; echo "$VAR"' | bait
# Translate to stdout
bait install.sh > install.fish
# Source your favorite script
bait < script.sh | source
curl script.sh | bait | source
# Suppress warnings on stderr (or BAIT_QUIET=1)
bait --quiet install.sh > install.fish
# Prevent helper injection (or BAIT_NO_HELPERS=1)
bait --no-helpers install.sh > install.fishLoad helpers to directly source bash scripts:
bait helper source > ~/.config/fish/functions/source.fish
bait helper . > ~/.config/fish/functions/..fishLoad all helpers:
for helper in (bait helper --names)
bait helper $helper > ~/.config/fish/functions/$helper.fish
endBind a shortcut to paste bash snippet into fish:
bind ctrl-b 'commandline --insert (fish_clipboard_paste | bait --no-helpers)'- Compatibility Guide: reference for (un)supported features
- Developer Guide: architectural principles & developer workflows