Reputation: 503
If I run a custom bash function under shell console:
~/w/dotfiles/ruby [g:master-] ¶ repository_root
/Users/tian/Documents/workspace/dotfiles
And if I run the custom bash function under IRB:
irb(main):001:0> `repository_root`
(irb):1: command not found: repository_root
=> ""
How could I get the same result in IRB?
# declare
repository_root () {
if git_is_repository ; then
git_show_repository_root
fi
}
Upvotes: 3
Views: 1546
Reputation: 246744
Assuming your function is in one of your bash profile files, you want to start up an interactive (-i
) login (-l
) shell to execute (-c
) your function:
output = %x{bash -lic 'repository_root'}
Upvotes: 2
Reputation: 871
One way to do this is to make a command out of the function.
Here's a short how-to
.bin
directory in your HOME
and add it to $PATH
in .bash_rc
..bin
.source .bash_rc
to update the $PATH
variable you just changed.fnx
, just use the back tick operator or exec
to run
the command - exec("fnx")
Upvotes: 1
Reputation:
where is repository_root
declared?
.bash_profile? .bashrc?
try to source that file before using repository_root
`. /path/to/file/declaring/repository_root; repository_root`
Upvotes: 0