GithubHelp home page GithubHelp logo

tbodt / bass Goto Github PK

View Code? Open in Web Editor NEW

This project forked from edc/bass

0.0 1.0 0.0 74 KB

Make Bash utilities usable in Fish shell

License: MIT License

Shell 33.40% Python 59.37% Makefile 7.23%

bass's Introduction

Bass

Bass makes it easy to use utilities written for Bash in fish shell.

Regular bash scripts can be used in fish shell just as scripts written in any language with proper shebang or explicitly using the interpreter (i.e. using bash script.sh). However, many utilities, such as virtualenv, modify the shell environment and need to be sourced, and therefore cannot be used in fish. Sometimes, counterparts (such as the excellent virtualfish) are created, but that's often not the case.

Bass is created to make it possible to use bash utilities in fish shell without any modification. It works by capturing what environment variables are modified by the utility of interest, and replay the changes in fish.

You might not need Bass for simple use cases. A great simple alternative (suggested by @jorgebucaran) is to just use exec bash -c "source some-bash-setup.sh; exec fish".

Installation

Bass is compatible with fish versions 2.6.0 and later.

Manually

Use the Makefile.

make install will copy two files to ~/.config/fish/functions/.

make uninstall will remove those two files.

Relaunch the shell for the change to take effect.

omf install bass

With Fisher

fisher install edc/bass

With Fundle

Add

fundle plugin 'edc/bass'

to your fish config, relaunch the shell and run fundle install.

Example

Bass is simple to use. Just prefix your bash utility command with bass:

> bass export X=3
> echo $X
3

Notice that export X=3 is bash syntax. Bass "transported" the new bash environment variable back to fish.

Bass has a debug option so you can see what happened:

> bass -d export X=4
# updating X=3 -> 4
set -g -x X 4

nvm

Here is a more realistic example, using the excellent nvm:

> bass source ~/.nvm/nvm.sh --no-use ';' nvm use iojs
Now using io.js v1.1.0

Note that semicolon is quoted to avoid being consumed by fish.

This example takes advantage of the nvm bash utility to switch to iojs. After the command, iojs is accessible:

> which iojs
/Users/edc/.nvm/versions/io.js/v1.1.0/bin/iojs

You can then very easily pack the command as a function and feel more at home:

> funced nvm
nvm> function nvm
           bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
       end

> nvm list
->  iojs-v1.1.0
         system
> nvm ls-remote
        v0.1.14
        v0.1.15
        
> funcsave nvm
...

(--no-use is an important option to nvm.sh. See #13 for background.)

bass's People

Contributors

alex7kom avatar crshoverride avatar daveyarwood avatar edc avatar elijahlynn avatar evanrelf avatar fabioantunes avatar jimt avatar jorgebucaran avatar josephfrazier avatar junaid-shahid avatar kouk avatar maksathanja avatar markcial avatar mojotx avatar neominik avatar nirvdrum avatar paparomeo avatar popbones avatar rouge8 avatar shouya avatar tbodt avatar thatneat avatar zavorka avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.