Not clear on how to use this with bash functions.
dessalines opened this issue · 8 comments
I do this with fish functions that look like
function lunch
bass source build/envsetup.sh \; lunch $argv
return $status
end
@dessalines this is good to close? If not, please provide more details. Thanks!
If bass isn't going to support bash -> fish functions, then its good to close, and add that as a disclaimer on the readme.
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
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?
@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>
Bass imports aliases differently than you're describing above, it puts them all as fish aliases.
@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.