Zsh

About
Zsh is a shell designed for interactive use, although it is also a powerful scripting language. ZSH, also known as Z-Shell, is a command line shell similar in function to the Korn Shell, Bash, and assorted other modern command line interfaces. Zsh is a powerful shell with a high amount of configurability.

Install
The default use flags should be fine for most of users. To install zsh, run

If you need autocompletion, you also need to emerge zsh-completion:

Usage
To start zsh, run

You will then be prompted to configure zsh. Press q for now as we'll configure it manually. If you want to set it as your default shell, then do

or run as root

or edit and change the shell manually.

Shell History
Add something like this to to enable shell history in zsh (Create it if it doesn't already exist).

Tab completion
To enable tab completion (Portage completions and Gentoo prompt), you need to add the following to your

It's also recommended to cache the completions. To achieve this, add to your.

Keys
If you find certain keys on your keyboard don't work, try using bindkey. First type then type  then the key that you want to bind (enclose this in single quotation marks). Then add the function you want it to bind to (You can use TAB completion for that!).

For example: on a macbook, the delete key is something like this:

bindkey '\e[3~' delete-char ^     ^-- Here i typed del and got a list of possible functions. '-- Here I pressed -v-

Put the command you generate into your to have the key work. This kind of key binding is incredibly powerfull and zsh has bindings set to make the shell behave as either emacs or vim! Check out their website documentation under keymaps.

Prompt Configuration
Don't like the default Gentoo prompt? No problem! You can make your prompt look like almost anything you want.

Automatic
Zsh comes with many built in prompts from which to choose. To choose one of the available prompts, first run (under Zsh):

You can now run the command to get a preview of all the prompts Zsh comes with, and  to actually set that to your prompt for the current shell. To make the changes permanent, add a something like the following to your :

where is the name of your desired prompt from  or

Manual
You can also change the prompt by hand rather than relying on the Zsh builtins. All that is required is to set the variable in your. Here are some examples:

Looks like (user @ mycomputer) %

Looks like user@mycomputer [ /current/working/dir ] %

You can also add colors!

Looks like (where 22:33 is the time) user AT mycomputer (22:33) %

Much more information can be found at the zsh website. Prompt expansion sequences, in particular, are here: http://zsh.sourceforge.net/Doc/Release/zsh_12.html#SEC40

You can also put a prompt at the RIGHT of the terminal by setting the variable in the same way.

SSH hosts tab completion
To have zsh complete ssh hosts out of your .ssh/known_hosts add this

Colorize STDERR
To color your stderr add the following lines to

This will color the stderr line red. You will find that many programs are programmed to use stderr instead of stdout for outputting information, dhclient for instance. For the most part this works fine.

Is the fixed version with better flushing when multiple lines are displayed.

There are another ways to colorize error output:


 * 1) stderred replaces system libc calls. It may doesn't colorize all stderr out stream but do it synchronously with standart output thus stdout and stderr do not mix.
 * 2) app-misc/hilite acts as a proxy between application and terminal, it reads its stderr and then puts it to terminal wrapped with color codes.

Directory in the title bar
To automatically display the current directory in the xterm title bar add the following lines to :

Equals
Emerge will fail when exact package and version is given due to feature of zsh which treats "=" differently compared to bash. To make work, (un)set: