Skip to content
项目

bouk/babelfish has 261 GitHub stars and 7 forks. GitHot measured 0 stars in 24 hours and 0 in 7 days. Last checked 2026-11-23 18:40 UTC. Last push 2025-01-27.

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

关于

Translate bash scripts to fish

开发工具

README.md

原文

babelfish

Translate bash scripts to fish.

Why?

Because I got annoyed by having to use fish-foreign-env or bass, which are slow, since they create multiple bash processes. With this program I can translate bash scripts to fish, and run them directly in fish.

But how?

babelfish parses the script using mvdan.cc/sh, and then translates bash expressions to the equivalent fish code. That's it! You can find the code that walks the AST and emits fish code here.

Install

If you have Homebrew, just run:

brew install babelfish

Else:

go install bou.ke/babelfish@latest

Example

# Pass some code on stdin to translate it
$ echo 'f() { export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket); local cool=yep; }' | babelfish
function f
  set -gx SSH_AUTH_SOCK (gpgconf --list-dirs agent-ssh-socket | string collect; or echo)
  set -l cool 'yep'
end
# Pass the result to source to load it into fish
$ echo 'echo Nice to meet you user $UID' | babelfish | source
Nice to meet you user 502
# Or install the shell hook!
$ source babel.fish
$ source chruby.sh
$ chruby
   ruby-2.5
   ruby-2.6
   ruby-2.7

To do

Probably still a lot. There's a couple variables like $BASH_SOURCE that aren't translated, and not all arithmetic expressions are implemented either. Pull requests and issues welcome!

探索相关项目

加载中…