ubuntu 安裝並配置zsh


(1)安裝

sudo apt-get install zsh

(2)設置默認shell(默認裝到/bin/zsh )

which zsh | sudo tee -a /etc/shells 
sudo chsh -s /bin/zsh

二.配置(通過oh my zsh)

1.安裝 oh my zsh

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

2.同步環境變量

source ~/.bashrc

原因:安裝zsh后之前配置的環境變量和別名等都在~/.bashrc中,而現在生效的是.zshrc

3.安裝插件(安裝需要的就可以了)

3.1  語法高亮插件zsh-syntax-highlighting :輸入的命令中間有錯的時候會自動顯示紅色

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

3.2 自動補全插件 zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

3.3 自動跳轉插件 autojump

git clone git://github.com/joelthelion/autojump.git
cd autojump
./install.py
# 根據安裝完成后的提示,在~/.zshrc最后添加下面語句:
vim ~/.zshrc    
[[ -s /home/misfit/.autojump/etc/profile.d/autojump.sh ]] && source /home/misfit/.autojump/etc/profile.d/autojump.sh

4.啟用插件

# 編輯~/.zshrc   
vim ~/.zshrc    
# 找到plugins后括號里添加安裝的插件名字
plugins=( git 
            autojump 
            zsh-autosuggestions 
            zsh-syntax-highlighting
            )
# 最后刷新
source ~/.zshrc    

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM