我不知道如何描述它.它恰好发生在我使用vim并设置shell = bash -l时.然后我发现一个名为mm的命令可以在终端中执行,不能在vim中执行.
我还发现,当我在run.sh中编写此命令并执行此脚本时.它仍然报告找不到命令.我认为我的$HOME / .bash \*文件和$HOME / .profile一定有问题.我确信.profile与.bashrc几乎相同.

解决方法:

来自$man bash:

When bash is invoked as an interactive login shell, or as a
non-interactive shell with the –login option, it first reads
and executes commands from the file /etc/profile, if that file exists.
After reading that file, it looks for ~/.bash\_profile,
~/.bash\_login, and ~/.profile, in that order, and **reads and
executes commands from the first one that exists and is readable.**


When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc, if that file exists.

所以:

shell   | files loaded    
--------+-----------------
bash -l | /etc/profile    
        | ~/.bash_profile 
        | ~/.bash_login
        | ~/.profile     
--------+-----------------
bash -i | ~/.bashrc

标签: shell, bash, linux, terminal, vim

相关文章推荐

添加新评论,含*的栏目为必填