Skip to main content Zsh with persistent config, history and oh-my-zsh : r/unRAID

Zsh with persistent config, history and oh-my-zsh

Hi guys!

I put together my zsh setup yesterday, maybe someone will find it useful.

It has:

  • oh-my-zsh

  • history

  • zsh-autosuggestions

  • zsh-syntax-highlighting

Steps

  1. First enable zsh with Nerd Pack, if you haven't already.

  2. Install User Scripts plugin

  3. Edit your /boot/config/go file and put this in the end:

# 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

You can of course also run the scripts manually first and create the .zshrc in your /root/ to try it out before rebooting.

Edit: Formatting



Once I setup zsh/oh-my-zsh/plugins..... All I ever do is archive copy the entire root folder onto my array every time my array shuts down. Then when array start up, I copy it back into root folder. Nothing fancy and works great. My simple method also avoids writes to my Unraid flash drive....a good thing to do if you value the longevity of your flash drive

2

I followed your guide, but whenever I log in, I still have to type "zsh" to enter the zsh shell. Does anyone know how to get directly into the zsh shell?

1

Change your shell to the zsh shell...

1
Continue this thread

Thx for writing this this up!

I currently experience this when login in via ssh. Anything I should do about it?

You can see the changelog with \omz changelog``

__ __

____ / /_ ____ ___ __ __ ____ _____/ /_

/ __ \/ __ \ / __ \__ / / / / /_ / / ___/ __ `

/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /

\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/

/____/

Hooray! Oh My Zsh has been updated!

To keep up with the latest news and updates, follow us on Twitter: https://twitter.com/ohmyzsh

Want to get involved in the community? Join our Discord: https://discord.gg/ohmyzsh

Get your Oh My Zsh swag at: https://shop.planetargon.com/collections/oh-my-zsh

[oh-my-zsh] Insecure completion-dependent directories detected:

drwxrwxrwx 2 root root 40 Sep 29 16:43 /root/.oh-my-zsh/cache/completions

[oh-my-zsh] For safety, we will not load completions from these directories until

[oh-my-zsh] you fix their permissions and ownership and restart zsh.

[oh-my-zsh] See the above list for directories with group or other writability.

[oh-my-zsh] To fix your permissions you can do so by disabling

[oh-my-zsh] the write permission of "group" and "others" and making sure that the

[oh-my-zsh] owner of these directories is either root or your current user.

[oh-my-zsh] The following command may help:

[oh-my-zsh] compaudit | xargs chmod g-w,o-w

[oh-my-zsh] If the above didn't help or you want to skip the verification of

[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to

[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.

Tower ~ #

1

This looks like just an update notice from oh-my-zsh, it's normal.

2

ok, thanks.

1
Continue this thread
Continue this thread