Featured image of post 命令行用户的oh-my-zsh配置

命令行用户的oh-my-zsh配置

Linux/macOS/WSL用户的oh-my-zsh shell和vim airline配置

配置shell

效果展示:

Shell Appearence

特点

安装

  1. 安装 Meslo Nerd 字体

    下载以下四个字体文件:

    若直接点击上述链接无法下载,可使用如下链接:https://cloud.jinli.cyou/s/ZbX2XocirqcATPe

    双击各文件并点击安装按钮,然后电脑上包括命令行终端在内的的各个软件就可以使用MesloLGS NF字体了。

    请参考p10k Font来为Windows Power Shell、macOS Terminal等命令行终端工具配置MesloLGS NF字体。

  2. 更新 apt

    1
    
    sudo apt update
    
  3. 安装依赖的工具库 (git, wget, python3, pip3)

    1
    
    sudo apt install wget git python3-dev python3-pip python3-setuptools
    
  4. 安装zsh

    • Ubuntu, Debian 及Debian系衍生系统

      1
      
      sudo apt install zsh
      
    • Arch Linux 或 Manjaro

      1
      
      sudo pacman -S zsh
      
    • macOS已自带zsh

  5. 通过wget安装 oh-my-zsh

    1
    
    sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    
  6. 安装 powerlevel10k

    1
    
    git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
    
  7. 安装插件和工具

    • 命令自动补全建议zsh-autosuggestions
      1
      
      git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
      
    • 命令语法高亮zsh-syntax-highlighting
      1
      
      git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
      
  8. 下载配置文件,并链接到用户根目录下

    1. 从GitHub下载 ShellConfig
      1
      2
      3
      
      mkdir -p ~/Documents/GitHub
      cd ~/Documents/GitHub
      git clone https://github.com/jin-li/ShellConfig.git 
      
    2. 备份旧配置文件
      1
      2
      
      mv ~/.bashrc ~/.bashrc_bak
      mv ~/.zshrc ~/.zshrc_bak
      
    3. 将配置文件链接到 home 目录
      1
      2
      3
      
      ln ~/Documents/GitHub/ShellConfig/.bashrc ~/.bashrc
      ln ~/Documents/GitHub/ShellConfig/.zshrc ~/.zshrc
      ln ~/Documents/GitHub/ShellConfig/.p10k.zsh ~/.p10k.zsh
      
  9. 重启命令行终端

配置Vim

Vim Appearance

特点

前提

Debian系统默认的vim版本是不支持插件功能的vim-tiny。运行如下命令可核对你的vim版本:

1
vi --version

若命令输出显示"Small version without GUI",则意味着你电脑上的 vimvim-tiny。你可以使用如下命令安装正常完整版本的vim

1
2
sudo apt remove vim-tiny
sudo apt install vim

配置

  1. 安装 Vundle

    1
    
    git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
    
  2. 链接配置文件到 home 目录

    1
    
    ln ~/Documents/GitHub/ShellConfig/.vimrc ~/.vimrc
    
  3. vim内安装插件。在vim命令模式下运行下面的命令:

    1
    
    :PluginInstall
    

    由于在配置文件中已经声明了这些插件,所以输入上述命令并敲击回车键后这些插件会自动开始安装,可能需要数秒到数分钟来完成安装。

  4. 也可以通过 Vundle 安装其他插件。

Licensed under CC BY-NC-SA 4.0
最后更新于 Oct 12, 2022 00:00 UTC
comments powered by Disqus