kidonng/bait

๐Ÿ› Bash to fish transpiler

โ˜… 4Forks 0GoGitHub โ†—Compare

README

๐Ÿ› Bait: Almost Idiomatic Transpiler

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

Note

Want the reverse (fish โ†’ Bash)? Checkout Hook!

Install

  • GitHub

    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

    nix profile install github:kidonng/bait

Usage

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.fish

Advanced

Load helpers to directly source bash scripts:

bait helper source > ~/.config/fish/functions/source.fish
bait helper . > ~/.config/fish/functions/..fish

Load all helpers:

for helper in (bait helper --names)
    bait helper $helper > ~/.config/fish/functions/$helper.fish
end

Bind a shortcut to paste bash snippet into fish:

bind ctrl-b 'commandline --insert (fish_clipboard_paste | bait --no-helpers)'

Docs

Contributors

kidonng

Issues