Featured image of post oh-my-zsh Shell and Neovim Configuration for Commandline Users

oh-my-zsh Shell and Neovim Configuration for Commandline Users

An elegant configuration for Linux/macOS commandline shells and vim airline

Shell Configuration

Here’s how it looks like:

Shell Appearence

Features

Install

Method 1: Use Installation Script (Recommend)

  1. Download the installation script:

    1
    
    curl -s https://raw.githubusercontent.com/jin-li/ShellConfig/main/install_OhMyZsh_p10k.sh -o install_OhMyZsh_p10k.sh
    
  2. Run the script:

    Do NOT run it in root NOR using sudo, just run it as a normal user. When it prompts for password, then enter the root or sudo password.

    1
    2
    
    chmod +x install_OhMyZsh_p10k.sh
    ./install_OhMyZsh_p10k.sh
    

Method 2: Manual Install

  1. Install Meslo Nerd Font

    Download these four ttf files:

    Double-click on each file and click “Install”. This will make MesloLGS NF font available to all applications on your system.

    For setting up the font in the preference of the terminals, please refer to p10k Font.

  2. Install zsh

    • Ubuntu, Debian & derivatives

      1. Update apt sources

        1
        
        sudo apt update
        
      2. Install prerequisite tools (git, wget, python3, pip3)

        1
        
        sudo apt install wget git python3-dev python3-pip python3-setuptools
        
      3. Install zsh

        1
        
        sudo apt install zsh
        
    • Arch Linux or Manjaro

      1
      
      sudo pacman -S zsh
      
    • Fedora

      1
      
      sudo dnf install zsh
      
  3. Install oh-my-zsh via wget

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

    1
    
    git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
    
  5. Install plugins and tools

    • 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
      
  6. Download configuration files and link to home directory

    1. Download ShellConfig from GitHub
      1
      2
      3
      
      mkdir -p ~/Documents/GitHub
      cd ~/Documents/GitHub
      git clone https://github.com/jin-li/ShellConfig.git 
      
    2. Backup old configuration files
      1
      2
      
      mv ~/.bashrc ~/.bashrc_bak
      mv ~/.zshrc ~/.zshrc_bak
      
    3. Link configuration files to home directory
      1
      2
      3
      
      ln ~/Documents/GitHub/ShellConfig/.bashrc ~/.bashrc
      ln ~/Documents/GitHub/ShellConfig/.zshrc ~/.zshrc
      ln ~/Documents/GitHub/ShellConfig/.p10k.zsh ~/.p10k.zsh
      
  7. Restart terminal

Vim Configuration

Vim Appearance

Motivation

I migrated from vim to Neovim because of the better performance and more features.

LazyVim is a starter-friendly configuration for Neovim with the commonly used plugins. It is easy to install and use.

Method 1: Use Installation Script (Recommend)

  1. Download the installation script:

    1
    
    curl -s https://raw.githubusercontent.com/jin-li/ShellConfig/main/install_LazyVim.sh -o install_LazyVim.sh
    
  2. Run the script:

    1
    2
    
    chmod +x install_LazyVim.sh
    ./install_LazyVim.sh
    

Method 2: Manual Install

  1. Remove vim-tiny or vim-minimal

    The default vim in Debian OS is vim-tiny (in Fedora is vim-minimal), which does not support the plugins. Use following command to check your vim version first before using this configuration.

    1
    
    vi --version
    

    If there is “Small version without GUI” in the output, it means your vim is vim-tiny or vim-minimal. You can remove it:

    • Debian / Ubuntu
      1
      
      sudo apt remove vim-tiny
      
    • Fedora
      1
      
      sudo dnf remove vim-minimal
      
  2. Install Neovim

    Then install Neovim.

    • Debian / Ubuntu

      Since LazyVim requires Neovim 0.8 or later, in Ubuntu 22.04, the neovim version is 0.6.1. Therefore, We need to install the newer version of neovim from the official website.

      1. Download the pre-built binaries of Neovim from the official website
        1
        
        curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz
        
      2. Extract the downloaded file
        1
        
        sudo tar -C /opt -xzf nvim-linux64.tar.gz
        
        This will install Neovim to /opt/nvim-linux64 directory.
      3. Create a symbolic link to the Neovim executable
        1
        
        sudo ln -s /opt/nvim-linux64/bin/nvim /usr/bin/nvim
        
    • Fedora

      In Fedora 40, the Neovim version is 0.9.5, which is new enough to use LazyVim. So we can install it using dnf directly.

      1
      
      sudo dnf install neovim
      
  3. Install LazyVim

    Refer to the official website, we can install LazyVim using the following command:

    1. Install LazyVim

      1
      
      git clone https://github.com/LazyVim/starter ~/.config/nvim
      
    2. Remove the .git folder, so you can add it to your own repo later

      1
      
      rm -rf ~/.config/nvim/.git
      
    3. First time run nvim will install the plugins automatically. It may take a while to finish.

      1
      
      nvim
      

Replace macOS Terminal

After installing LazyVim, I found that the display effect of LazyVim in macOS Terminal is very poor, with dim colors and low contrast:

LazyVim in macOS Terminal

The reason is that the macOS Terminal’s color scheme does not support 256 true colors, while LazyVim defaults to a 256-color color scheme. I heard that iTerm2 supports 256 true colors, so I decided to migrate from the macOS built-in terminal to iTerm2. After installing iTerm2, you need to set iTerm2 to use the Meslo Nerd font you downloaded and installed earlier. Then open LazyVim in iTerm2, it looks much better now:

LazyVim in iTerm2

comments powered by Disqus