DeskTux

Linux on Desktops

User Tools

Site Tools


Sidebar

apps:zsh

ZSH

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.

zlogin

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):

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

zlogout

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:

clear

zprofile

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.

zshenv

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.

zshrc

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

zshrc.gz
Size: 1,8 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 syste-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, 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.
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
apps/zsh.txt · Last modified: 2016-08-11 20:44 by jens