Linux on Desktops

User Tools

Site Tools



The Z-Shell is IMHO a way better shell to use than the BASH for your daily work. It is very user-friendly, feature-rich and powerful. Especially the tab-completion handling of the ZSH is superior and one of the best I've ever seen. A good and well configured shell is the first thing you need to make your Console and commandline more useful.

Of course this shell needs some configuring and finetuning like everything else. That's why I have prepared my own configuration files for you.

For more information about the Z-Shell you should visit its website. Another great resource is the book ZSH - Die magische Shell (German). Unfortunately it seems to be hard to get. There are some very expensive offerings at Amazon. And no, you can't get mine ;-)

The configuration files

The files are listed in alphabetical order.

Depending on its location the corresponding file is a system-wide configuration file or for you personally.


You'll find this file in either /etc/zsh or as ~/.zlogin.

Everything within this file is executed at login. Mine looks like this; maybe parts of it will be useful to you (“linuxlogo” and “fortune” must be installed):

linuxlogo -u -y
/usr/games/fortune -s
echo -e "\nIP Information\n--------------"
/bin/ip address show|awk '/inet/ {print $2}'|grep -vE '(|::1/128)'
echo -e "\nDisk Free Information\n---------------------"
df -h -x tmpfs


You'll find this file in either /etc/zsh or as ~/.zlogout.

Similar to the zlogin file everything in here is executed on logout. Mine is quite simple:



You'll find this file in either /etc/zsh or as ~/.zprofile.

This file is similar to /etc/profile. Mine just contains the Debian defaults which I will leave out here.


You'll find this file in either /etc/zsh or as ~/.zshenv.

Used for environment variables. Mine just contains the Debian defaults which I will leave out here.


You'll find this file in either /etc/zsh or as ~/.zshrc.

Size: 2,0 kB

This is the main configuration file of the Z-Shell and contains the major part of the configuration. The file is too long to quote here, please feel free to download it. Also, it contains quite a lot of control sequences for the colours which would get lost during copy/paste.

The file contains two sections, the upper is suitable for a system-wide configuration as it sets some options (umask and prompt color) depending on whether you are root or not. Of course you can choose to ignore that and use that configuration for yourself only (i.e. only settings for non-root will be activated).

The lower part is suitable for either your personal configuration or as a system-wide configuration, depending on your wishes. Personally I'd advise to put as much in your personal configuration as possible. Just unpack the file and have a look at the comments for more information.

This file will give you these options (amongst others):

  • A nice colored prompt which tells you user, hostname, PTY (if root), git branch (if user), path and time. The color is mainly red when root and green when you are working as user.
    A colored prompt is also very useful when scrolling in your terminal or console history to distinguish the output from what you typed!
  • A umask based on UID as well (less strict as user).
  • Nice and useful dircolors, aliases and environment variables.
  • Extension of the $PATH environment variable which adds the “sbin-paths” to $PATH when using sudo.
  • Rehashing of the completion functions so newly installed programs are immediately available in the tab-completion after installation.
  • Extended and shared history.
  • Updates of the terminal title w/ either username and hostname (when you are at a prompt) or the currently running command (when running a command).
  • An example of how to learn a specific filetype extension for a specific command when using tab-completion. E.g. if you type “gunzip” and then press <Tab> you only want to see “.gz”-files.
    The only extension I could think of that the ZSH doesn't know about out-of-the-box is “.par2”. So the example is about “par2repair” and .par2-files.


The history command of the ZSH works different than the BASH history. By default, only the last 15 history entries are shown. You could just grep or less your ~/.zsh_history file for getting the information you want, but there are more convenient ways.

history Show the last 15 entries of your history.
history 0 Show all history entries.
history -i Show the last 15 history entries including human readable timestamps.
history -i 0 Show all history entries including human readable timestamps.

All history entries are always numbered. Note that human readable timestamps only work with the extended history enabled.


Enter your comment:
apps/zsh.txt · Last modified: 2024-05-18 18:36 by jens