Giter VIP home page Giter VIP logo

Comments (8)

edc avatar edc commented on August 18, 2024 2

@dessalines I am not sure I understand your question. But you can use all the functions in .bashrc, as long as you source it first in the same bass call:

bass source ~/.bashrc \; foo

Bass invokes bash behind the scene in non-interactive mode, so it does not source .bashrc automatically, and you'll have to source it manually to use any function in it.

For example, my .bashrc defines a function ll that does ls -l. bass ll will fail, but bass source ~/.bashrc \; ll will work just fine.

$ cat .bashrc
function ll {
  ls -l
}

$ bass ll
bass: ll: command not found

$ bass source .bashrc \; ll
total 8
<snip>

from bass.

tbodt avatar tbodt commented on August 18, 2024

I do this with fish functions that look like

function lunch
    bass source build/envsetup.sh \; lunch $argv
    return $status
end

from bass.

edc avatar edc commented on August 18, 2024

@dessalines this is good to close? If not, please provide more details. Thanks!

from bass.

dessalines avatar dessalines commented on August 18, 2024

If bass isn't going to support bash -> fish functions, then its good to close, and add that as a disclaimer on the readme.

from bass.

edc avatar edc commented on August 18, 2024

Actually bash function should be easily usable as @tbodt pointed out. Another example:

$ cat x.sh
function foo {
  echo 'foo'
}
$ bass source x.sh \; foo
foo

Basically, you source before you invoke the function. Wrap the whole thing in a function/alias if you use it a lot:

$ alias foo 'bass source x.sh \; foo'
$ foo
foo

from bass.

dessalines avatar dessalines commented on August 18, 2024

I have a .bashrc with many aliases, and functions in it. If I can run bass source .bashrc, and it picks up all the aliases, why shouldn't it be able to handle many functions, if the parsing is that trivial?

from bass.

dessalines avatar dessalines commented on August 18, 2024

Bass imports aliases differently than you're describing above, it puts them all as fish aliases.

from bass.

edc avatar edc commented on August 18, 2024

@dessalines you are right. The approach above only works with bash functions. Aliases are imported differently. If an imported alias uses bash functions, then it will break.

My suggestion is to convert the few aliases you rely on into functions, and save them in a new file, say, aliases.sh, and then do bass source foo.sh ; source aliases.sh ; bar, where bar is the converted alias.

from bass.

Related Issues (20)

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.