mycommand是lib/work.sh文件中的一个函数。
cat .bashrc
source /home/lib/work.sh这意味着mycommand是自动生成的。
mycommand可以在终端执行。
现在,要使用vim test.txt、shift+"来编辑一个文件以进入vim的命令模式,输入!mycommand,
/bin/bash: mycommand: command not found
shell returned 127
Press ENTER or type command to continue为什么mycommand在vim中找不到?
发布于 2018-08-03 09:08:38
有不同类型的shells 登录壳和非登录壳的区别? (查找.bashrc部件)
并不是所有的公司都在采购.bashrc,因此work.sh也没有来源。
为了解决您的问题,您需要导出您的函数以使其可用于子subshell。
myfun() {
echo "Hello!"
}
export -f myfun--
vim
:!myfun行得通!
https://unix.stackexchange.com/questions/460256
复制相似问题