I have created a bash function, in its own .sh
file, which I want to use from within Vim, and later use if from within the lightline config file. I have tried many ways, but I cannot make it work.
Specifically, I have tried with the !source
command, but it doesn't work. Since I'm using a macOS, I have added the sourcing of the function script in the proper place in the /etc/bashrc
file, so the sourcing will happen in a non-interactive shell.
Still nothing.
My command is called myTest
and it is:
#!/usr/bin/env bash
function myTest{
echo "OK"
}
and is at the test_function.sh
file.
Since I have read the relevant question of Why doesn't vim recognize bash self-made functions, I have copied the test_function.sh
to /etc/
and I have at my /etc/bashrc
if [ -z "$PS1" ]; then
source /etc/test_function.sh
return
fi
This is why in MacOS, the non-interactive shells read the /etc/bashrc
or /etc/profile
files.
Also I have added the sourcing of the test_function.sh
file in the /etc/profile
file, having:
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
else
source /etc/test_function.sh
fi
When I'm trying to do in Vim :!myTest
I'm always getting Command not found
.
Any help?