zsh

From Gentoo Wiki
Jump to: navigation, search

zsh (Z shell) is an interactive login shell that can also be used as a powerful scripting language interpreter. It is similar to bash and the Korn shell, but offers extensive configurability, powerful command-line completion, file globbing, and spelling correction.

Installation

USE flags

Optional USE flags for app-shells/zsh:
USE flag (what is that?) Default Recommended Description
caps No Use Linux capabilities library to control privilege
debug No No Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see http://www.gentoo.org/proj/en/qa/backtraces.xml
doc No Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
examples No Yes Install examples, usually source code
gdbm Yes Add support for sys-libs/gdbm (GNU database libraries)
maildir No Add support for maildir (~/.maildir) style mail spools
pcre Yes Add support for Perl Compatible Regular Expressions
static No  !!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically
unicode Yes Yes Add support for Unicode

Emerge

Install app-shells/zsh:

root #emerge --ask zsh

Add-ons

app-shells/zsh-completion

Emerging app-shells/zsh-completion enables auto-completion for arguments of commands, which is one of the advantages zsh has over other shells:

root #emerge --ask app-shells/zsh-completion
Note
To enable 'zsh-completion' globally (for most programs), add it to the USE variable in /etc/portage/make.conf

app-shells/gentoo-zsh-completions

Emerging app-shells/gentoo-zsh-completions enables Gentoo specific auto-completion for arguments of Portage and other Gentoo commands:

root #emerge --ask app-shells/zsh-completion

When installing this package be sure to add the following to the respective ~/.zshrc files:

FILE ~/.zshrcEnabling Portage completions and Gentoo prompt for zsh
autoload -U compinit promptinit
compinit
promptinit; prompt gentoo

To enable a cache for the completions add:

FILE ~/.zshrcEnabling Portage completions and Gentoo prompt for zsh
zstyle ':completion::complete:*' use-cache 1

Configuration

Invocation

user $zsh

Upon running zsh for the first time as a new user, you will be greeted by a basic configuration dialog. The setup process can be skipped by pressing q. If the setup process is skipped zsh can be setup manually.

Setting zsh as the default shell

To make zsh the default shell for a user, run:

user $chsh -s /bin/zsh

File

zsh's main configuration file is located in each user's home directory at ~/.zshrc. Reload this file in running shells for the changes to take effect:

user $source ~/.zshrc
Note
Reloading via the source command is only necessary when instances of zsh are already in memory after changes are made to the shell's configuration file.

See also

External resources