Call bash function using vim external command

后端 未结 4 2005
既然无缘
既然无缘 2021-01-13 22:00

I use vim\'s :! external command function all the time, usually providing % as an argument to the shell command. For example :

:!psql -f %

4条回答
  •  情书的邮戳
    2021-01-13 22:46

    Export your functions. That is:

    psql-h1() { /usr/bin/psql -hh1 -d mydb "$@"; }
    
    export -f psql-h1  ### <-- THIS RIGHT HERE
    

    This will make them available to any copy of bash run as a child process, even if it's a noninteractive shell and so doesn't read .bashrc.

提交回复
热议问题