记录一次WSL Ubuntu 添加环境变量后打开终端时shell语法不高亮的问题
为WSLubuntu 添加node环境变量
nano .bash_profile
export NODE_HOME=/usr/local/share/node-v12.18.3-linux-x64
export PATH=$NODE_HOME/bin:$PATH
export NODE_PATH=$NODE_HOME/lib/node_modules
在/home/{username}/.bashrc文件末尾添加:
source $HOME/.bash_profile
再次登录Ubuntu时高亮消失
然而,直接键入命令source .bashrc
时,恢复高亮
原因
登录式交互shell配置文件的加载方式如下:
/etc/profile > .bash_profile > .bash_login > .profile > .bash_logout.
非登录式交互shell配置文件的加载方式如下:
/etc/bash.bashrc > .bashrc
WSL为登录式交互shell,然而我在配置node环境变量时创建了.bash_profile
文件,覆盖了后续配置文件的加载,使得.bashrc
没有加载。
因此shell无法高亮显示
解决方法:
将.bash_profile改为与配置文件不冲突的名称