• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created over 4 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Translate bash scripts to fish

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

GO111MODULE=on go get bou.ke/babelfish

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!

More Repositories

1

monkey

Monkey patching in Go
Go
3,235
star
2

staticfiles

staticfiles compiles a directory of files into an embeddable .go file
Go
505
star
3

dark-mode-notify

Run a script whenever dark mode changes in macOS
Swift
190
star
4

extractdata

Live at http://extractdata.club
Go
169
star
5

gonerics

Generics for go
Go
114
star
6

statictemplate

Statictemplate is a code generator for Go's text/template and html/template.
Go
76
star
7

go-faster

You can always Go faster
Go
49
star
8

HTTPS4All

Rewrite HTTP hosts to HTTPS whenever possible
Swift
35
star
9

b

My setup
Nix
30
star
10

kubectl-dashboard

Instantly get a Kubernetes dashboard
Go
15
star
11

https-everywhere-host-list

Tool to convert HTTPS Everywhere rules to a list of hosts that support HTTPS.
HTML
12
star
12

arduino-nix

Manage your arduino-cli with Nix
Nix
12
star
13

memorizationbot

Source code for https://memorizationbot.com/
Go
10
star
14

deoplete-markdown-links

Complete wiki links and tags in Markdown.
Python
7
star
15

esbuild-ruby

Ruby
6
star
16

unsafer

This is a bad idea
Go
4
star
17

proxy-now

Use Tasker to add custom voice commands to Google Now
Java
4
star
18

gameboy-emu

Go
3
star
19

go-lisp

A lisp interpreter in go
Go
3
star
20

objfile

Go
3
star
21

splendimax

Splendor AI that uses minimax to play
Rust
3
star
22

elfie

Package elfie takes an 'ELF-selfie' of the current process.
Go
3
star
23

file2const

Generates a Go file containing the given files as strings
Go
3
star
24

rust-sysv-ipc

Implementation of Sysv IPC for Rust
Rust
2
star
25

symme

Retrieve the symbol table for the current process
Go
2
star
26

boggle-solver

Show all possible words given a boggle board
C++
2
star
27

procmaps

Package procmaps provides a parser for the /proc maps format
Go
2
star
28

esbuilder

Integrate esbuild into Rails
Ruby
1
star
29

AprilTags

Apriltags bindings for Swift
Swift
1
star
30

uva

My various uva solutions
C++
1
star
31

whoamits

Service that tells you who you are based on Tailscale
Go
1
star
32

hyves-stats

Track Hyves' users' stats
PHP
1
star
33

s3redirect

Just redirects every request to a presigned URL of a certain bucket.
Go
1
star
34

cross-chain-nix

Binutils cross-compilation toolchains for nix
Nix
1
star
35

tempdb

Go
1
star
36

orm

An ORM for Go that's good. WIP
Go
1
star
37

gotre

Go Tail Recursion Eliminator
Go
1
star
38

rayray

Rust
1
star
39

putio

This is a webOS application that immediately redirects to tv.put.io
HTML
1
star
40

fast-postgres

Fast postgres Docker image for tests
1
star
41

motion-pong

Motion controlled pong game for school project
Python
1
star
42

ctxdb

ctxdb provides access to the database through a Context
Go
1
star
43

webgl-sand

A falling sand game completely implemented in webgl
JavaScript
1
star
44

tools

Misc command line utilities
Go
1
star
45

skype-db

Ruby
1
star
46

go-template-parser

Go
1
star
47

txdriver

txdriver provides transaction isolation for Go SQL tests
Go
1
star
48

watch-dragonball-xbmc

An addon that makes it possible to watch all Dragonball series through XBMC
Python
1
star
49

terraform-provider-ejson

A Terraform provider that can decrypt ejson on-the-fly
Go
1
star
50

exhaustive-enum

Exhaustive-enum is an exhaustive enum checker for Go. It can be used to make sure you don't miss any cases when switching over an enumeration.
Go
1
star
51

varlink_systemd

1
star