The zsh package contains a command interpreter (shell) usable as an interactive login shell and as a shell script command processor. Of the standard shells, zsh most closely resembles ksh but includes many enhancements.
Development versions of BLFS may not build or run some packages properly if LFS or dependencies have been updated since the most recent stable versions of the books.
Download (HTTP): https://www.zsh.org/pub/zsh-5.9.1.tar.xz
Download MD5 sum: 5492bfe9a4afacdb2d1d81c27a1d44fa
Download size: 3.3 MB
Estimated disk space required: 48 MB (includes documentation and tests)
Estimated build time: 1.6 SBU (Using parallelism=4; includes documentation and tests)
When there is a new zsh release, the old files shown above are moved to a new server directory: https://www.zsh.org/pub/old/.
Valgrind-3.27.1 and yodl
The documentation files contain references to zsh configuration
files in /etc, but we'll use
/etc/zsh to hold these configuration
files instead. The build system will update those references if the
yodl package is available, but
it's out of the scope of BLFS. As a result, we need to fix the
references manually:
sed -e 's|/etc/z|/etc/zsh/z|g' \
-i Doc/*.*
Install zsh by running the following commands:
./configure --prefix=/usr \
--sysconfdir=/etc/zsh \
--enable-etcdir=/etc/zsh \
--enable-cap \
--enable-gdbm \
--enable-pcre &&
make &&
makeinfo Doc/zsh.texi --html -o Doc/html &&
makeinfo Doc/zsh.texi --plaintext -o zsh.txt &&
makeinfo Doc/zsh.texi --html --no-split --no-headers -o zsh.html
If you have texlive-20250308 installed, you can build the documentation in PDF format by issuing the following command:
texi2pdf Doc/zsh.texi -o Doc/zsh.pdf
To test the results, issue: make check.
Now, as the root user:
make install &&
make infodir=/usr/share/info install.info &&
make htmldir=/usr/share/doc/zsh-5.9.1/html install.html &&
install -v -m644 zsh.{html,txt} Etc/FAQ /usr/share/doc/zsh-5.9.1
If you built the PDF format of the documentation, install it by
issuing the following command as the root user:
install -v -m644 Doc/zsh.pdf /usr/share/doc/zsh-5.9.1
--sysconfdir=/etc/zsh and
--enable-etcdir=/etc/zsh:
These parameters are used so that all the zsh configuration files are consolidated into
the /etc/zsh directory. Omit these
parameters if you wish to retain historical compatibility by having
all the files located in the /etc
directory.
--enable-cap: This option
enables POSIX capabilities.
--enable-gdbm: This option
enables the use of the GDBM
library.
--enable-pcre: This option
allows zsh to use the PCRE2
regular expression library in shell builtins.
There are a whole host of configuration files for zsh including /etc/zsh/zshenv, /etc/zsh/zprofile, /etc/zsh/zshrc, /etc/zsh/zlogin and /etc/zsh/zlogout. You can find more information
on these in the zsh(1) and related
manual pages.
Create a basic /etc/zsh/zprofile
file. Like /etc/profile provided in
The Bash Shell Startup Files,
it sets up some helper functions and some basic parameters, then
loads the scripts in /etc/profile.d:
install -vdm755 /etc/zsh &&
cat > /etc/zsh/zprofile << "EOF"
# Begin /etc/zsh/zprofile
# Written for Beyond Linux From Scratch
# System wide environment variables and startup programs.
# Functions to help us manage paths. Second argument is the name of the
# path variable to be modified (default: PATH)
pathremove () {
local IFS=':'
local NEWPATH
local DIR
local PATHVARIABLE=${2:-PATH}
for DIR in ${(P)=PATHVARIABLE} ; do
if [ "$DIR" != "$1" ] ; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
fi
done
export $PATHVARIABLE="$NEWPATH"
}
pathprepend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="$1${(P)PATHVARIABLE:+:${(P)PATHVARIABLE}}"
}
pathappend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="${(P)PATHVARIABLE:+${(P)PATHVARIABLE}:}$1"
}
# Set the initial path
export PATH=/usr/bin
# Attempt to provide backward compatibility with LFS earlier than 11
if [ ! -L /bin ]; then
pathappend /bin
fi
if [ $EUID -eq 0 ] ; then
pathappend /usr/sbin
if [ ! -L /sbin ]; then
pathappend /sbin
fi
unset HISTFILE
fi
# Set some defaults for graphical systems
export XDG_DATA_DIRS=${XDG_DATA_DIRS:-/usr/share}
export XDG_CONFIG_DIRS=${XDG_CONFIG_DIRS:-/etc/xdg}
export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/tmp/xdg-$USER}
for script in /etc/profile.d/*.sh ; do
if [ -r $script ] ; then
. $script
fi
done
unset script
# End /etc/zsh/zprofile
EOF
The first time zsh is executed, you will be prompted by messages
asking several questions. The answers will be used to create a
~/.zshrc file. If you wish to run
these questions again, run zsh
/usr/share/zsh/5.9.1/functions/zsh-newuser-install
-f.
There are several built-in advanced prompts. In the zsh shell, start advanced
prompt support with autoload -U
promptinit, then promptinit. Available prompt
names are listed with prompt
-l. Select a particular one with prompt <prompt-name>. Display all
available prompts with prompt
-p. Except for the list and display commands
above, you can insert the other ones in ~/.zshrc to be automatically executed when the
shell starts, with the prompt you chose.
Update /etc/shells to include the
zsh shell program names (as the
root user):
cat >> /etc/shells << "EOF"
/bin/zsh
EOF