Install Requirements Packages
opkg update && opkg install ca-certificates zsh curl git-http
Install oh-my-zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Set zsh as default (thanks to @mlouielu)
which zsh && sed -i -- 's:/bin/ash:'`which zsh`':g' /etc/passwd
To prevent lock-outs after accidentially removing zsh(as explained in the wiki) you can add a check for zsh
and fallback to ash
in /etc/rc.local
(thanks to @fox34):
# Revert root shell to ash if zsh is not available
if grep -q '^root:.*:/usr/bin/zsh$' /etc/passwd && [ ! -x /usr/bin/zsh ]; then
# zsh is root shell, but zsh was not found or not executable: revert to default ash
[ -x /usr/bin/logger ] && /usr/bin/logger -s "Reverting root shell to ash, as zsh was not found on the system"
sed -i -- 's:/usr/bin/zsh:/bin/ash:g' /etc/passwd
fi
To make oh-my-zsh persistent after system upgrades, there are several options. I suggest to remove unneeded plugins and themes, since they will increase config (backup) size by a few MB.
Option A: Adding /root to backup file list
Go to LuCI -> System -> Backup/Flash Firmware -> Tab "Configuration" -> Add /root
Option B: Install oh-my-zsh to /etc/zsh and keep user files there
Step 1: Install or move oh-my-zsh to /etc/zsh
Install oh-my-zsh into
/etc/zsh
upon initial setup (see instructions). If you already installed oh-my-zsh into/root/
, move it from there:mkdir /etc/zsh mv /root/.oh-my-zsh /etc/zsh/oh-my-zsh sed -i -- 's:/root/.oh-my-zsh:/etc/zsh/oh-my-zsh:g' /root/.zshrc
Step 2: Add /etc/zsh to backup files
Go to LuCI -> System -> Backup/Flash Firmware -> Tab "Configuration" -> Add /etc/zsh
Step 3: Move and symlink zsh-related user files to /etc/zsh to keep them after sysupgrades
Login in a separate shell (for security reasons) to check functionality.
Step 4: Check and restore symlinks on reboot
Append the following commands in
/etc/rc.local
(beforeexit 0
) to restore the symlinks after every reboot, if they are missing:Prevent lock outs due to a missing zsh installation
To prevent lock-outs after accidentially removing zsh (as explained in the wiki), you can add a check for
zsh
and fallback toash
in/etc/rc.local
: