oh-my-zsh安装与配置

oh-my-zsh是一款社区驱动的命令行(shell)工具,它包括丰富的终端主题、插件机制,并且拥有丰富的内置插件,方便命令行操作。

oh-my-zsh 下载

oh-my-zsh官网:https://ohmyz.sh/
官网首页显示Install oh-my-zsh,点击跳转。
打开terminal(mac自带的shell软件),执行如下命令即可下载。

Install oh-my-zsh via curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Install oh-my-zsh via wget
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

下载成功提示

xxxx% sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" 
Cloning Oh My Zsh...
Cloning into '/Users/xxxx/.oh-my-zsh'...
remote: Counting objects: 831, done.
remote: Compressing objects: 100% (700/700), done.
remote: Total 831 (delta 14), reused 775 (delta 10), pack-reused 0
Receiving objects: 100% (831/831), 567.67 KiB | 75.00 KiB/s, done.
Resolving deltas: 100% (14/14), done.
Looking for an existing zsh config...
Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc
             __                                     __   
      ____  / /_     ____ ___  __  __   ____  _____/ /_  
     / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ 
    / /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / 
    \____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  
                            /____/                       ....is now installed!
Please look over the ~/.zshrc file to select plugins, themes, and options.
p.s. Follow us at https://twitter.com/ohmyzsh.
p.p.s. Get stickers and t-shirts at http://shop.planetargon.com

oh-my-zsh配置

oh-my-zsh配置主要包括主题配置和插件配置。oh-my-zsh拥有丰富的主题以及插件。

查看oh-my-zsh内置主题

oh-my-zsh默认主题是“Robby Russell”,可以通过ls -al ~/.oh-my-zsh/themes/查看可使用的内置主题

设置主题

oh-my-zsh的配置文件路径是~/.zshrc
执行nano ~/.zshrc编辑配置文件,在配置文件中找到ZSH_THEME = "Robby Rusell"字段,将Robby Rusell字段更改为可使用的内置主题即可。
更改结束后执行source ~/.zshrc激活配置

oh-my-zsh常用插件配置

oh-my-zsh常用插件包括zsh-autosuggestions、zsh-syntax-highlighting、z、extract等插件,前两个插件需要通过git下载,后两个插件是oh-my-zsh内置插件

zsh-autosuggestions功能是自动补全提示命令。执行git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions下载zsh-autosuggestions到指定插件目录

zsh-syntax-highlighting功能是命令高亮提示,以直观显示可使用命令,可使用命令高亮为绿色。执行git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting下载zsh-syntax-highlighting到指定插件目录

执行nano ~/.zshrc编辑配置文件,在配置文件中找到plugins=字段,在该字段中添加可使用插件。

plugins = (git zsh-autosuggestions zsh-syntax-highlighting z extract)

注意:插件名称用空字符隔开。

自定义主题powerlevel10k配置可自行搜索配置教程。

posted @ 2025-05-05 14:38  wesleylee0614  阅读(784)  评论(0)    收藏  举报