Skip to main content

ZSH and Unraid

This set of instructions is 95% based on this reddit thread (see below for an archived version if the link doesn't work)

  1. Install NerdTools plugin (this replaces the legacy NerdPack)
  2. Install User Scripts plugin (in Community Applications)
  3. edit /boot/config/go and add the following to the file:

    # Install Oh-My-Zsh 
    HOME="/root" sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" 

  4. Create your .zshrc file at /boot/config/extra/.zshrc:

    export ZSH="/root/.oh-my-zsh"
    
    ZSH_THEME="robbyrussell"
    
    DISABLE_UPDATE_PROMPT="true"
    
    HISTSIZE=10000
    SAVEHIST=10000
    HISTFILE=/root/.cache/zsh/history
    
    plugins=(
      zsh-autosuggestions
      zsh-syntax-highlighting
    )
    
    source $ZSH/oh-my-zsh.sh
    
    # User configurations
    
    alias l='ls -lFh'     #size,show type,human readable
    alias la='ls -lAFh'   #long list,show almost all,show type,human readable

  5. Create a new script named "zsh" in user scripts and set it to "At Startup of Array" 
  6. Edit the script you just created /boot/config/plugins/user.scripts/scripts/zsh/script
    #!/bin/bash
    
    HOME=/root
    OH_MY_ZSH_ROOT="$HOME/.oh-my-zsh"
    ZSH_CUSTOM="$HOME/.oh-my-zsh/custom"
    OH_MY_ZSH_PLUGINS="$ZSH_CUSTOM/plugins"
    OH_MY_ZSH_THEMES="$ZSH_CUSTOM/themes"
    
    mkdir -p $OH_MY_ZSH_PLUGINS
    mkdir -p $OH_MY_ZSH_THEMES
    
    # Install zsh-autosuggestions
    if [ ! -d "$OH_MY_ZSH_PLUGINS/zsh-autosuggestions" ]; then
            echo "  -> Installing zsh-autosuggestions..."
            git clone https://github.com/zsh-users/zsh-autosuggestions $OH_MY_ZSH_PLUGINS/zsh-autosuggestions
    else
            echo "  -> zsh-autosuggestions already installed"
    fi
    
    # Install zsh-syntax-highlighting
    if [ ! -d "$OH_MY_ZSH_PLUGINS/zsh-syntax-highlighting" ]; then
            echo "  -> Installing zsh-syntax-highlighting..."
            git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $OH_MY_ZSH_PLUGINS/zsh-syntax-highlighting
    else
            echo "  -> zsh-syntax-highlighting already installed"
    fi
    
    chmod 755 $OH_MY_ZSH_PLUGINS/zsh-autosuggestions
    chmod 755 $OH_MY_ZSH_PLUGINS/zsh-syntax-highlighting
    
    chsh -s /bin/zsh
    
    # Remove oh-my-zsh default .zshrc
    rm /root/.zshrc
    
    # Make sure the necessary directories are existing
    mkdir -p /root/.cache/zsh/
    mkdir -p /boot/config/extra/
    
    # Make sure history file exists
    touch /boot/config/extra/history
    
    # Symlink .zshrc and history files
    cp -sf /boot/config/extra/.zshrc /root/.zshrc
    cp -sf /boot/config/extra/history /root/.cache/zsh/history
  7.  Reboot your server and you should now have zsh setup (or run the scripts manually and create .zshrc file in /root/)

References