Using Oh My Zsh in unRAID?


Recommended Posts

Hey!, 

 

So, I wanna use zsh+Oh My Zsh in the unRAID shell but I'm having some issues with the setup so that it gets re-installed on every reboot. I enabled zsh using the nerd pack plugin then I can install OMZ manually and it works perfectly but I can't figure out how to make it persist after a reboot. 

 

In summary. I enabled zsh on the nerd pack and added these lines to my go script: 
 

Quote

# Install Oh My ZSH!
chsh -s $(which zsh)
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
cp /boot/extra/scripts/oh-my-zsh/.zshrc /root/

 

The result is that I get zsh as the default shell correctly but the weird thing is that when I SSH into unRAID using PuTTy I don't have Oh My Zsh installed and yet in the command prompt in the actual server (as in, the video output from that computer) I see it installed correctly. 

 

Am I missing anything?. 

Link to comment
  • 1 year later...

Yes, running from the go file or from user scripts, you will have issues (just like I did). The install script uses home variables, which do not expand properly (instead of ~/ becoming /root, it becomes //).

 

I broke down the installer script, and fixed it for unraid. Here is what I use:

ZSH="/root/.oh-my-zsh"
umask g-w,o-w
git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH
cp "$ZSH"/templates/zshrc.zsh-template /root/.zshrc
sed "/^export ZSH=/ c\\
export ZSH=\"$ZSH\"
" /root/.zshrc > /root/.zshrc-omztemp
mv -f /root/.zshrc-omztemp /root/.zshrc
chsh -s $(which zsh)
env zsh -l

 

Link to comment
  • 2 weeks later...
  • 1 month later...
On 1/1/2019 at 10:25 PM, d2dyno said:

I figured out a simpler way, just define $HOME for scripts:


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

 

Thought I'd just mention......zsh is in the unraid NerdPack plugin......that is probably the easiest way to install zsh and have it persist through reboots. If you haven't used NerdPack plugin, I'd suggest looking into it. Makes installing various tools and have them persist extremely easy

Edit: Apologies.....you referring to Oh-My-Zsh.....

Edited by Stupifier
Link to comment
  • 1 year later...
7 minutes ago, xthursdayx said:

Late post, but hopefully one of you all might see this. I was just wondering how you're handling making your .zshrc and any plugins persistent? Thanks!

I used the User Scripts plugin to run this script on first start of array :

#!/bin/bash

# umask setup
umask 077

# Variable Setup
CONFIG=/boot/config/ssh
HOME_SSH=/root/.ssh
ZSH="/root/.oh-my-zsh"

mkdir -p $HOME_SSH
cp $CONFIG/pre-set/* $HOME_SSH
chmod 700 $HOME_SSH
chmod 644 $HOME_SSH/id_rsa.pub
chmod 600 $HOME_SSH/id_rsa
chmod 600 $HOME_SSH/authorized_keys

### Install zsh shits
HOME="/root"
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
umask g-w,o-w
chsh -s $(which zsh)
env zsh -l

newplugins="git tmux zsh-autosuggestions"

sed -i  "s/(git)/($newplugins)/" /root/.zshrc
sed -i "s#\(ZSH_THEME *= *\).*#\1agnoster#" /root/.zshrc
echo "cd /mnt/user/" >> /root/.zshrc
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH/custom/plugins/zsh-autosuggestions
chmod 700 /root/.oh-my-zsh/custom/plugins/zsh-autosuggestions
###

# Copy terminal (zsh) history
cp /boot/config/.zsh_history /root

Combined with this array stop script to copy ZSH history and SSH keys:

#!/bin/bash

# Copy terminal (zsh) history
touch /boot/config/.zsh_history
echo "$(cat /root/.zsh_history)" >> /boot/config/.zsh_history

# Variable Setup
CONFIG=/boot/config/ssh
HOME_SSH=/root/.ssh
# Copy any new keys on exit
rsync -avhW $HOME_SSH/ $CONFIG/pre-set

As for .zshrc (or aliases), I use /boot/config/go to write to /etc/profile on startup (how I was taught here to do it):

# Re-make aliases on boot
echo "
#### Aliases copied from /boot/config/go ####
alias size='du -c -h -d 1 | sort -h'
export TERM=xterm-color
#### End Aliases ####">>/etc/profile

These are just example aliases and settings, use your own (though I do love that size alias)

Edited by d2dyno
  • Like 1
  • Thanks 5
Link to comment

Thanks @d2dyno !

 

Just to clarify, was there a reason you added these lines to /boot/config/go rather than your .zshrc?

On 12/7/2020 at 5:23 PM, d2dyno said:


# Re-make aliases on boot
echo "
#### Aliases copied from /boot/config/go ####
alias size='du -c -h -d 1 | sort -h'
export TERM=xterm-color
#### End Aliases ####">>/etc/profile

 

Edited by xthursdayx
Link to comment
  • 2 years later...
On 12/7/2020 at 2:23 PM, d2dyno said:

I used the User Scripts plugin to run this script on first start of array :

 

Combined with this array stop script to copy ZSH history and SSH keys:

 

As for .zshrc (or aliases), I use /boot/config/go to write to /etc/profile on startup (how I was taught here to do it):

 

These are just example aliases and settings, use your own (though I do love that size alias)

 

Super helpful - thank you very much - late to the game by three years - but was setting up a new box and this was helpful as i was relearning how to set things up

Link to comment
  • 5 months later...

I have been using Oh My Zsh in Linux for sometime. Recently I have installed and set up unRaid on a couple servers. Unfortunately, with countless research, I have not be able to find/locate a complete walk through guide of setting up, configuring, and using Oh My Zsh in the unRaid software. I was wondering if such documentation/video exists? I have also been wanting to change or modify the command prompt gui, but have not be able to locate information towards that as well. If someone could point me into the right direction, it would be greatly appreciated.

Link to comment
On 12/14/2023 at 5:19 PM, AaronIA said:

I have been using Oh My Zsh in Linux for sometime. Recently I have installed and set up unRaid on a couple servers. Unfortunately, with countless research, I have not be able to find/locate a complete walk through guide of setting up, configuring, and using Oh My Zsh in the unRaid software. I was wondering if such documentation/video exists? I have also been wanting to change or modify the command prompt gui, but have not be able to locate information towards that as well. If someone could point me into the right direction, it would be greatly appreciated.

 

Just a few days ago I was able to get successfully set this up using this:

 

https://gist.github.com/khongi/23103333ff0493e7cf109d6494515fba

 

I slightly modified it to install powerlevel10k theme, a couple other oh-my-zsh plugins, and some other dotfiles.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.