Skip to main content
added 101 characters in body
Source Link
Xxxo
  • 187
  • 9

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?

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

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?

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?

added 24 characters in body
Source Link
Xxxo
  • 187
  • 9

Call custom bash function from vim config fileVim

I have created a bash function, in its own .sh file, which I want to use from within a Vim config file, 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 aat 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

Also I have added the sourcing of the test_function.shzsh 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 :!testmyTest I'm always getting Command not found.

Any help?

Call custom bash function from vim config file

I have created a bash function, in its own .sh file, which I want to use from within a Vim config file, 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:

function myTest{
    echo "OK"
}

and is a 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

Also I have added the sourcing of the test_function.shz 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 :!test I'm always getting Command not found.

Any help?

Call custom bash function from Vim

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

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?

Source Link
Xxxo
  • 187
  • 9

Call custom bash function from vim config file

I have created a bash function, in its own .sh file, which I want to use from within a Vim config file, 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:

function myTest{
    echo "OK"
}

and is a 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

Also I have added the sourcing of the test_function.shz 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 :!test I'm always getting Command not found.

Any help?