Zsh功能强大,是我的默认Shell,并使用Oh My Zsh和zsh-autosuggestions等插件。
但是当我使用ssh远程连接我的电脑时,Zsh没有引用.profile文件。仔细检查后,也没有引用/etc/profile等与login shell相关的配置文件,导致了我的PATH等环境变量配置不正确。怎么解决呢?
安装配置Zsh
安装
-
安装Zsh和Oh My Zsh:
sudo apt install zsh git wget sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" chsh -s /bin/zsh -
配置Zsh并添加zsh-autosuggestions等插件:
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting sudo apt install autojump修改
~/.zshrc:plugins=(sudo pip autojump zsh-autosuggestions zsh-syntax-highlighting)主题我喜欢用
candy。
完善Zsh配置
-
修改
/etc/zsh/zprofile文件,在文件末尾添加一行(这个应该默认就有的,不知道为什么Ubuntu没加):source /etc/profile -
创建
~/.zprofile文件,添加如下内容:source ~/.profile -
创建
~/.zlogout文件,添加如下内容:source ~/.bash_logout
这就可以完美解决了。参考了ArchWiki Zsh和ArchWiki Bash。
以下是懒人版:
echo "source /etc/profile" | sudo tee --append /etc/zsh/zprofile
echo "source ~/.profile" >> ~/.zprofile
echo "source ~/.bash_logout" >> ~/.zlogout