Skip to content

Instantly share code, notes, and snippets.

@netanel-haber
Last active June 30, 2026 11:43
Show Gist options
  • Select an option

  • Save netanel-haber/acad0e295392ea888bdb23e30a447f07 to your computer and use it in GitHub Desktop.

Select an option

Save netanel-haber/acad0e295392ea888bdb23e30a447f07 to your computer and use it in GitHub Desktop.
Install zsh on a machine, without sudo
#!/bin/bash
set -euo pipefail
set -x
: "${TARGET:?usage: "TARGET=<HOME>" $0}"
NCURSES_VERSION=6.4
NCURSES_SOURCE="ncurses-$NCURSES_VERSION"
ZSH_VERSION=5.9
ZSH_SOURCE=zsh_source
ZSH_INST=$TARGET/zsh_inst
cd ~
# Download zsh
wget -O zsh.tar.xz https://sourceforge.net/projects/zsh/files/zsh/$ZSH_VERSION/zsh-$ZSH_VERSION.tar.xz/download
mkdir $ZSH_SOURCE
unxz zsh.tar.xz
tar -xvf zsh.tar -C $ZSH_SOURCE --strip-components 1
cd $ZSH_SOURCE
# Install ncurses - a dependency of zsh that may not be present on the machine
curl -LO https://mirrors.kernel.org/gnu/ncurses/$NCURSES_SOURCE.tar.gz
tar xf $NCURSES_SOURCE.tar.gz
cd $NCURSES_SOURCE
./configure --prefix="$TARGET/.local" --with-shared --without-debug --enable-widec
make -j"$(nproc)"
make install
cd ..
# Install zsh
CPPFLAGS="-I$TARGET/.local/include" LDFLAGS="-L$TARGET/.local/lib" ./configure --prefix="$ZSH_INST"
make -j"$(nproc)"
make install
# Test zsh
"$ZSH_INST/bin/zsh" --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment