Skip to content

Support us

Authors: fire1ce | Created: 2022-04-03 | Last update: 2022-12-15

Install oh-my-zsh on OpenWrt

You can install oh-my-zsh on OpenWrt, make sure to use the Prevent User Lockout option since many users been locked out of their sessions since the zsh shell was not installed or loaded properly.

Whats' ZSH

Z-shell (Zsh) configuration. is a Unix shell that can be used as an interactive login shell and as a shell scripting command interpreter. Zsh is an enhanced Bourne shell with many enhancements, including some Bash, ksh and tcsh features.

What's Oh-My-Zsh

Oh My Zsh is an open source, community-driven framework for managing your zsh configuration.

Installation of oh-my-zsh

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

Prevent User Lockout

To prevent lock-outs after accidentially removing zsh (thanks to @fox34) (as explained in the wiki you can add a check for zsh and fallback to ash in /etc/rc.local:

# 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

Comments