Sie befinden sich im Service: RWTH High Performance Computing (Linux)

How to customize your Z shell (zsh)

How to customize your Z shell (zsh)

Das Bild zeigt ein Symbol, das einen hellblauen Umriss eines Dokuments darstellt. Auf dem Dokument befinden sich drei horizontale Linien, die jeweils von einem Häkchen begleitet werden. Diese Häkchen sind ebenfalls hellblau und symbolisieren eine Checkliste.

How to change the shell

All users get the Z shell (zsh) as their default login shell. Users who would like to work with a different shell (bash in the following example) should append the following lines of code to the end of their ~/.zshrc:

source /usr/local_host/etc/switch_login_shell bash

Please Note: Thorough support can only be provided for zsh.

You also have to add the line

. /usr/local_host/etc/bashrc

to your ~/.bashrc file in order to activate the modules system, cf. here.

zsh configuration files

zsh has a couple of configuration files. The most important ones are described in the following subsections.

~/.zshrc

This file is read whenever zsh is started as an interactive shell. Therefore you should use it in order to configure the interactive behaviour of your shell, e.g. for

  • environment variables like $EDITOR, $PAGER, extensions to $MANPATH
  • aliases
  • shell options (setopt ...)

To switch the command-line mode from 'emacs' (the default) to 'vi' use the following line:

bindkey -v

~/.zshenv

This file is read for every invocation of zsh and should therefore be as short as possible.

Please Note: ~/.zshenv must not contain any output to stdout, otherwise various programs (e.g. scp) will stop working. Moreover, you must not call any external zsh scripts here. An infinite recursion will occur otherwise.

At best, you should avoid calling external programs at all and limit yourself to the definition of environment variables only, e.g. extensions to $PATH.

~/.zlogout

This file is read whenever a zsh login shell terminates.

zuletzt geändert am 05.02.2024

Wie hat Ihnen dieser Inhalt geholfen?

Creative Commons Lizenzvertrag
Dieses Werk ist lizenziert unter einer Creative Commons Namensnennung - Weitergabe unter gleichen Bedingungen 3.0 Deutschland Lizenz