Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 95873 Details for
Bug 123322
Proposal for Zsh guide section in Gentoo documentation
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
zsh.xml
zsh.xml (text/plain), 9.31 KB, created by
Peter Weller (RETIRED)
on 2006-09-03 12:30:01 UTC
(
hide
)
Description:
zsh.xml
Filename:
MIME Type:
Creator:
Peter Weller (RETIRED)
Created:
2006-09-03 12:30:01 UTC
Size:
9.31 KB
patch
obsolete
><?xml version="1.0" encoding="UTF-8"?> ><!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> ><!-- $Header$ --> > ><guide link="/doc/en/zsh.xml" lang="en"> > ><title>zsh Configuration and Installation Guide</title> > ><author title="Author"> > <mail link="hak8@wp.pl">Henryk Konsek</mail> ></author> ><author title="Author"> > <mail link="morritt.andrew@gmail.com">Andrew Morritt</mail> ></author> ><author title="Editor"> > <mail link="chriswhite@gentoo.org">Chris White</mail> ></author> ><author title="Editor"> > <mail link="welp@01welp.co.uk">Peter Weller</mail> ></author> > ><abstract> >This guide shows how to install and configure zsh quickly. After >reading this document you will be able use many zsh features such >as advanced tab-completion, command correction and prompt management. ></abstract> > ><!-- The content of this document is licensed under the CC-BY-SA license --> ><!-- See http://creativecommons.org/licenses/by-sa/2.5 --> ><license/> > ><version>1.5</version> ><date>2006-08-03</date> > ><chapter> ><title>Installation</title> ><section> ><title>Installing zsh</title> ><body> > ><p> >To install <c>zsh</c> under Gentoo we need to emerge the <c>app-shells/zsh</c> >(<c>zsh</c> itself) and <c>app-shells/zsh-completion</c> (<c>zsh</c> >completion scripts) packages. ></p> > ><pre caption="Emerging zsh"> ># <i>emerge zsh zsh-completion</i> ></pre> > ></body> ></section> ></chapter> > ><chapter> ><title>Configuration</title> ><section> ><title>Introduction</title> ><body> > ><p> >To start <c>zsh</c> for a single session run <c>zsh</c>, for a more permanent >solution, please refer to the chapter on ><uri link="#doc_chap3">Saving settings</uri>. After the installation, ><c>zsh</c> seems to be very simple and rather limited in the area of >functionality. To change this, several configuration changes need to be >performed. ></p> > ></body> ></section> ><section> ><title>Advanced Tab-completion</title> ><body> > ><p> >To enable the famous <c>zsh</c> tab-completion system, you need to run the >following commands: ></p> > ><pre caption="Enabling completion"> >% <i>autoload -U compinit</i> >% <i>compinit</i> ></pre> > ><p> >Default completion style is quite plain and ugly. If you want to improve >its appearance, enter the following commands: ></p> > ><pre caption="Completion style improvements"> >% <i>zstyle ':completion:*:descriptions' format '%U%B%d%b%u'</i> >% <i>zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'</i> ></pre> > ></body> ></section> ><section> ><title>Command correction</title> ><body> > ><p> >It is also a good idea to enable the auto-correction of the commands typed: ></p> > ><pre caption="Enabling correction"> >% <i>setopt correctall</i> ></pre> > ></body> ></section> ><section> ><title>Prompts</title> ><body> > ><p> >The prompt may seem quite boring however, but we can fix it easily in several >steps. First, we need to initialize advanced prompt support: ></p> > ><pre caption="Enabling advanced prompts"> >% <i>autoload -U promptinit</i> >% <i>promptinit</i> ></pre> > ><p> >Available prompts samples may be printed via the <c>prompt -p</c> command. Now >we can activate our favorite one: ></p> > ><pre caption="Choosing a sample prompt"> ><comment>(Replace oliver with the prompt of your choice)</comment> >% <i>prompt oliver</i> ></pre> > ><note> >If you're playing around with the different prompts, and you don't want to >see a sample of every one, you can use <c>prompt -l</c> to list the prompts >available. ></note> > ><p> >Another option is to create your own prompt. To do this you will need to set >the PS1 environment variable. ></p> > ><pre caption="A simple custom prompt"> >% <i>export PS1="[Test Prompt] > "</i> >[Test Prompt] > ></pre> > ><p> >While it is good to be able to create a custom text prompt, <c>zsh</c> also >provides many escape sequences that allow system information to be inserted >into the prompt. Some of the escape sequences available are: ></p> > ><table> ><tr> > <th>Sequence</th> > <th>Printed</th> ></tr> ><tr> > <ti>%T</ti> > <ti>System time (HH:MM)</ti> ></tr> ><tr> > <ti>%*</ti> > <ti>System time (HH:MM:SS)</ti> ></tr> ><tr> > <ti>%D</ti> > <ti>System date (YY-MM-DD)</ti> ></tr> ><tr> > <ti>%n</ti> > <ti>Your username</ti> ></tr> ><tr> > <ti>%B - %b</ti> > <ti>Begin - end bold print</ti> ></tr> ><tr> > <ti>%U - %u</ti> > <ti>Begin - end underlining</ti> ></tr> ><tr> > <ti>%d</ti> > <ti>Your current working directory</ti> ></tr> ><tr> > <ti>%~</ti> > <ti>Your current working directory, relative to ~</ti> ></tr> ><tr> > <ti>%M</ti> > <ti>The computer's hostname</ti> ></tr> ><tr> > <ti>%m</ti> > <ti>The computer's hostname (truncated before the first period)</ti> ></tr> ><tr> > <ti>%l</ti> > <ti>Your current tty</ti> ></tr> ></table> > ><p>These escape sequences may simply be inserted into the the environment >variable, PS1, and <c>zsh</c> will parse them automatically.</p> > ><pre caption="A more complex prompt"> >% <i>export PS1="[%* - %D] %d %% "</i> >[08:44:23 - 06-02-18] /home/username % ></pre> > ></body> ></section> ><section> ><title>History</title> ><body> > ><p> >Unfortunately the default <c>zsh</c> configuration in Gentoo does not include >command history support. Due to the fact that working with a shell with history >disabled is very frustrating, we should enter the following commands: ></p> > ><pre caption="Basic history configuration"> >% <i>export HISTSIZE=2000</i> >% <i>export HISTFILE="$HOME/.history"</i> > ><comment>(otherwise history won't be saved)</comment> >% <i>export SAVEHIST=$HISTSIZE</i> ></pre> > ><p> >It is very comfortable to search commands in history using up/down >arrow keys, especially after typing few first letters of desired command >under shell. For example: ></p> > ><pre caption="History searching based on the first letters of the commands"> ><comment>(Do not press Enter after typing)</comment> >% <i>vim /etc/</i> ><comment>(Now press up arrow key)</comment> >% <i>vim /etc/fstab</i> ><comment>(Press up arrow key once again)</comment> >% <i>vim /etc/X11/xorg.conf</i> ></pre> > ><p> >To enable the above feature, enter the following commands: ></p> > ><pre caption="Setting context searching"> >% <i>bindkey `tput kcuu1` history-beginning-search-backward >/dev/null 2>&1</i> >% <i>bindkey `tput kcud1` history-beginning-search-forward >/dev/null 2>&1 </i> ></pre> > ><p> >To prevent history from recording duplicated entries (such as <c>ls -l</c> >entered many times during single shell session) can set the ><c>hist_ignore_all_dups</c> option. ></p> > ><pre caption="Setting ignoring of duplicates "> >% <i>setopt hist_ignore_all_dups</i> ></pre> > ><p> >Is also a useful trick to prevent particular entries from being recorded >into a history by preceding them with at least one space. ></p> > ><pre caption="Preventing particular entry from being recorded"> >% <i>setopt hist_ignore_space</i> > ><comment>(This command won't be recorded. Note the extra space before it.)</comment> >% <i> cat /proc/i/do/not/want/to/remember</i> ></pre> > ></body> ></section> ><section> ><title>Miscellaneous settings</title> ><body> > ><p> >You can set the <c>autocd</c> option if you want to avoid tedious typing of ><c>cd</c> command while changing current directory (for example ><c>/etc</c> instead of <c>cd /etc</c>). ></p> > ><pre caption="Setting autocd option"> >% <i>setopt autocd</i> ></pre> > ><p> >If standard bash-like globbing does not satisfy you, <c>extendedglob</c> >option may be set to enable extended globbing (one similar to >regular expressions). ></p> > ><pre caption="Setting extended globbing"> >% <i>setopt extendedglob</i> ></pre> > ><p> >When option above is set, you are able to use extended globbing queries >such as <c>cp ^*.(tar|bz2|gz)</c>. ></p> > ></body> ></section> ></chapter> > ><chapter> ><title>Saving settings</title> ><section> ><title>Saving zsh settings</title> ><body> > ><p> >Once we have customized <c>zsh</c> the way we like it, it is a good idea to >save these options as the <c>zsh</c> defaults for the system. >One possible way to achieve this is to write our settings in the ><path>/etc/zsh/zshrc</path> script. Alternatively, we could make them the >defaults for our account only be editing <path>~/.zshrc</path>. ></p> > ><pre caption="An example zshrc"> >#!/bin/zsh > ># completion >autoload -U compinit >compinit > ># correction >setopt correctall > ># prompt >autoload -U promptinit >promptinit >prompt oliver ></pre> > ><p> >The last thing we need to do is set the zshrc script as >executable: ></p> > ><pre caption="Making zshrc executable"> >% <i>chmod a+x /etc/zsh/zshrc</i> ></pre> > ></body> ></section> ></chapter> > ><chapter> ><title>Making zsh the default shell</title> ><section> ><title>Option for users with root privileges</title> ><body> > ><p> >We can change shell for given user with <c>usermod</c> command. ></p> > ><pre caption="Switching to zsh permanently using usermod"> ># <i>usermod -s /bin/zsh username</i> ></pre> > ></body> ></section> ><section> ><title>Alternatives for non-root users</title> ><body> > ><p> >If your system administrator (despite gentle requests, that is) refuses to set >the shell to <c>zsh</c> for you, you have a number of options. One method is to >set <c>bash</c> to execute <c>zsh</c> on startup - all you need to do is make a >slight modification to your <path>~/.bashrc</path>. ></p> > ><pre caption="vim ~/.bashrc"> ><comment>(Add the following to your ~/.bashrc)</comment> >exec zsh ></pre> > ><p> >A second, prefered, method of changing shells is to use the <c>chsh</c> command >(a utility used to change a user's login shell), A normal user may only change >the login shell for his/her own account. As root, you can change the login shell >of any user. ></p> > ><pre caption="Switching to zsh permanently using chsh"> ># <i>chsh -s /bin/zsh username</i> ></pre> > ></body> ></section> ></chapter> ></guide>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 123322
:
80129
|
80133
|
80134
|
80144
|
80319
|
80320
|
80326
|
80327
|
93612
|
95857
| 95873