Difference between revisions of "Zsh (Česky)"

From ArchWiki
Jump to: navigation, search
Line 13: Line 13:
 
* Plně přizpůsobitelný
 
* Plně přizpůsobitelný
  
The Zsh FAQ offers [http://zsh.sourceforge.net/FAQ/zshfaq01.html#l4 more reasons] to use Zsh as your shell.
+
Zsh Faq nabízí [http://zsh.sourceforge.net/FAQ/zshfaq01.html#l4 více důvodů] proč používat Zsh.
  
==Installation Instructions==
+
== Instrukce pro instalaci ==
  
Before starting lets find out what shell is currently being used:
+
Než začneš, zjisti který shell právě používáš:
  
 
  $ echo $SHELL
 
  $ echo $SHELL
  
===Installing===
+
=== Instalace ===
  
To install the package for Zsh, run:
+
Pro instalaci Zsh balíku, spusť:
 
   
 
   
 
  # pacman -S zsh
 
  # pacman -S zsh
  
Before proceeding with the next step to make Zsh your default shell, you should ensure that it has been installed correctly by running Zsh in a xterm or in a tty:
+
Před nastavením Zsh jako impliticní shell se ujisti jestli byl nainstalován korektně jeho spuštěním např. v okně xtermu nebo tty:
  
 
  $ zsh
 
  $ zsh
  
If the installation has gone smoothly you should now find yourself staring at a rather unfamiliar prompt, for now just type exit:
+
Pokud instalace proběhla hladne, měl by jsi teď vidět neznámý prompt, zatím prostě napiš:
  
 
  $ exit
 
  $ exit
  
===Making Zsh your default shell===
+
=== Nastavení Zsh jako implicitní shell ===
  
To change a user's default shell without root access, the chsh command is used. The chsh command can be used to change a user's default shell without root access if the shell is listed in {{Filename|/etc/shells}}. If you installed Zsh using pacman, Zsh should already have an entry in {{Filename|/etc/shells}}.
+
Pro změnu uživatelského implicitního shellu bez rootovských oprávnění se používá příkaz chsh. Příkaz chsh lze použít pro změnu implicitního shellu bez rootovských oprvávnění jen pokud je shell uveden v souboru {{Filename|/etc/shells}}. Pokud jsi Zsh instaloval použitím pacmana, Zsh již by měl mít odpovídající záznam v {{Filename|/etc/shells}}.
  
To proceed you need to know the full path for Zsh, so run:
+
Pro pokračování potřebuješ znát plnou cestu k Zsh, proto spusť:
  
 
  $ which zsh
 
  $ which zsh
  
Change the default shell for the current user:
+
Změn implicitní shelll pro práve přihlášeného uživatele:
  
 
  $ chsh -s /bin/zsh
 
  $ chsh -s /bin/zsh

Revision as of 11:25, 11 December 2009

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n links end Zsh je mocný shell se kterým je možno pracovat jako s interaktivním shellem i jako se interpretrem skriptovacího jazyka. Je sice kompaktibilní se shellem Bash, nabízí však další možnosti jako:

  • Rychlost
  • Vylepšené doplňování klávesou TAB
  • Vzlepšený globbing
  • Vylepšená práce s poli
  • Plně přizpůsobitelný

Zsh Faq nabízí více důvodů proč používat Zsh.

Instrukce pro instalaci

Než začneš, zjisti který shell právě používáš:

$ echo $SHELL

Instalace

Pro instalaci Zsh balíku, spusť:

# pacman -S zsh

Před nastavením Zsh jako impliticní shell se ujisti jestli byl nainstalován korektně jeho spuštěním např. v okně xtermu nebo tty:

$ zsh

Pokud instalace proběhla hladne, měl by jsi teď vidět neznámý prompt, zatím prostě napiš:

$ exit

Nastavení Zsh jako implicitní shell

Pro změnu uživatelského implicitního shellu bez rootovských oprávnění se používá příkaz chsh. Příkaz chsh lze použít pro změnu implicitního shellu bez rootovských oprvávnění jen pokud je shell uveden v souboru Template:Filename. Pokud jsi Zsh instaloval použitím pacmana, Zsh již by měl mít odpovídající záznam v Template:Filename.

Pro pokračování potřebuješ znát plnou cestu k Zsh, proto spusť:

$ which zsh

Změn implicitní shelll pro práve přihlášeného uživatele:

$ chsh -s /bin/zsh

An alternative way to change a user's default shell is with the command usermod. The disadvantage of this method is that you must have root access. But multiple users default shell can be changed quickly as root, using usermod or chsh.

Change the default shell for multiple users, using usermod:

# usermod -s /bin/zsh username

Change the default shell for multiple users, using chsh:

# chsh -s /bin/zsh username
Note: The user needs to logout and log back in, to start using Zsh as their default shell.

After logging back in, the user can verify that Zsh is their default shell by:

$ echo $SHELL

If you do not have root access, and Zsh is not listed in Template:Filename but you would still like to use Zsh as your default shell, see this entry in the Zsh FAQ.

Configuration

Although Zsh is usable out of the box, it is almost certainly not set up the way you would like to use it, but due to the sheer amount of customisation available in Zsh, creating a Zsh config can be a daunting and time-consuming experience.

Included below is a sample configuration file, it provides a decent set of default options as well as giving examples of many ways that Zsh can be customised. In order to use this configuration save it as a file named Template:Filename. You can then apply the changes without needing to logout and then back in by running:

$ source ~/.zshrc

Simple .zshrc

Here is a simple Template:Filename, that should be sufficient to get you started:

Template:File

/etc/zprofile

Much like the Template:Filename used for Bash, this file is for global Zsh settings & is a good place from which to run scripts from Template:Filename and set up environment variables such as $PATH. When setting up $PATH etc. in Template:Filename and using a login-manager such as kdm, you may find those settings not being taken up by the window-manager, whereas they are when using Template:Filename.

Generally speaking, you can copy Template:Filename to Template:Filename.

An example configuration:

Template:File

Note: Zsh's PKGBUILD defines that profile is in /etc/profile, so reference to /etc/zprofile is a bit misleading...

Command Completion

Perhaps the most compelling feature of Zsh is its advanced autocompletion abilities. At the very least, you will want to enable autocompletion in your Template:Filename. To enable autocompletion, add the following to:

Template:File

For autocompletion with an arrow-key driven interface, add the following to: Template:File

Key Bindings

Zsh doesn't read Template:Filename, which tells the shell what commands sent by the terminal emulator mean. To have some standard key bindings working on Zsh, add something like this to:

Template:File

Prompts

There is a quick and easy way to set up a colored prompt in Zsh. Make sure that prompt is set to autload in your Template:Filename. This can be done by adding these lines to:

Template:File

You can now see available prompts by running the command:

$ prompt -l

To try one of the commands that is listed, use the command prompt followed by the name of the prompt you like. For example, to use the "walters" prompt, you would enter:

$ prompt walters

Advanced .zshrc

This is an example of a more advanced Template:Filename:

Template:File

There are many more ways that you can customise Zsh, obviously far too many to list here, see the Zsh manual for more information.

Sample .zshrc files

Here is a list of Template:Filename files. Feel free to add your own:

Enable Unicode (obsolete)

Note: Unicode is enabled by default on the official Arch Linux Zsh package.

The latest versions of Zsh support unicode characters. To enable it, just rebuild the package with the Arch Build System.

And add the option --enable-multibyte to:

Template:File

Uninstallation

If you decide that Zsh is not the shell for you and you want to return to Bash. You must first change your default shell back to Bash, before removing the Zsh package.

Follow, Zsh#Making Zsh your default shell to change the default shell back to Bash, just replace zsh with bash.

Now you can safely remove the Zsh package.

Warning: Failure to follow the above will result in all kinds of problems.

If you did not follow the above, you can still change the default shell back to Bash by editing /etc/passwd as root. For example:

from:

username:x:1000:1000:Full Name,,,:/home/username:/bin/zsh

to:

username:x:1000:1000:Full Name,,,:/home/username:/bin/bash

External Resources


  • IRC channel: #zsh at irc.freenode.org