记录 | ubuntu安装oh my zsh

安装 zsh

首先,查看一下你系统里所以的 shell

cat /etc/shells
# 查看当前用的shell
echo $SHELL 
sudo apt update
sudo apt install zsh #安装zsh

# 查看zsh路径
which zsh

# 将zsh设置成默认shell(不设置的话启动zsh只有直接zsh命令即可)
# 路径为 which zsh查看到的
chsh -s /usr/bin/zsh 

# 或者直接修改 /etc/shells,将/usr/bin/zsh提到最上面

# 记得重启生效
sudo reboot

# 也可直接在 ~/.bashrc 最后添加 zsh,这样每次打开都是终端都是zsh了

安装 Oh My Zsh

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

安装 Oh My Zsh 主题 spaceship

克隆主题下来:

sudo git clone https://github.com/spaceship-prompt/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"

将克隆下来的主题软连接到 zsh 的主题文件夹中

sudo ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"

修改 `~/.zshrc` 中的主题名

ZSH_THEME="spaceship"

在命令行输入 `source ~/.zshrc` 让 zsh 生效。


还有个好看的主题

sudo git clone https://github.com/zakaziko99/agnosterzak-ohmyzsh-theme.git "$ZSH_CUSTOM/themes/agnosterzak-ohmyzsh"

sudo ln -s "$ZSH_CUSTOM/themes/agnosterzak-ohmyzsh/agnosterzak.zsh-theme" "$ZSH_CUSTOM/themes/agnosterzak.zsh-theme"

ZSH_THEME="agnosterzak"

安装各种插件

oh my zsh有着大量插件,默认情况下只有git使用,下面介绍两种常用的插件安装方式,也是我自己在用的,非常推荐

配置autojump插件

sudo apt install autojump  # 这种方式无法初始化

# 换这种
git clone https://github.com/wting/autojump
cd autojump
./install.py

sudo vim ~/.zshrc
plugins=(git autojump)

[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh

配置zsh-autosuggestions插件

zsh-autosuggestions,历史命令智能提示插件。能帮助我们快速执行历史命令

执行以下命令下载更新插件

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

执行以下命令进入编辑界面

sudo vim ~/.zshrc

在plugins函数中添加插件zsh-autosuggestions(与git空格隔开)

plugins=(git autojump zsh-autosuggestions)
source ~/.zshrc

配置 zsh-syntax-highlighting插件

`zsh-syntax-highlighting`,语法高亮插件。当你输入时,这个插件将帮助你纠错

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

plugins=(git autojump zsh-autosuggestions zsh-syntax-highlighting)

source ~/.zshrc

你可能感兴趣的:(踩坑记录,linux,ubuntu,zsh,oh,my,zsh,spaceship,插件,主题)