ubuntu 安装并配置zsh

参考:

1.https://www.jianshu.com/p/4fde9ae77922

2.https://www.cnblogs.com/dhcn/p/11666845.html

一.安装zsh 

1.源码安装

(1)安装:

wget https://sourceforge.net/projects/zsh/files/latest/download
tar -xvJf zsh-5.7.1.tar.xz
cd zsh-5.7.1
./configure
make
sudo make install 

注意:Makefile是./configure之后才有的

添加zsh到shell名单中并修改默认shell设置

(2).设置默认shell  (默认装到/usr/local/bin/zsh )

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

logout后重新登录即可使用zsh 

警告:如果重新登录不可以用需要重启,一定要确保知道root密码,不然/bin/bash进不去了就废了,知道root密码还能改回来

2.直接安装

(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
# 根据安装完成后的提示,在~/.bashrc最后添加下面语句:
vim ~/.bashrc    
[[ -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    
复制代码

 

posted @   陈雪莲  阅读(2063)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!

welcome to myblog

点击右上角即可分享
微信分享提示