GRMLZSHRC May, 2009 %!target: man %!postproc(man): "^(\.TH.*) 1 " "\1 5 " = NAME = grmlzshrc - grml's zsh setup = SYNOPSIS = //zsh// [**options**]... = DESCRIPTION = The grml project provides a fairly exhaustive interactive setup (referred to as //grmlzshrc// throughout this document) for the amazing unix shell zsh (http://zsh.sourceforge.net). This is the reference manual for that setup (which is currently vastly incomplete; patches welcome). To use //grmlzshrc//, you need at least version 3.1.7 of zsh (although not all features are enabled in every version). //grmlzshrc// behaves differently depending on which user loads it. For the root user (**EUID** == 0) only a subset of features is loaded by default. This behaviour can be altered by setting the **GRML_ALWAYS_LOAD_ALL** STARTUP VARIABLE (see below). = STARTUP VARIABLES = Some of the behaviour of //grmlzshrc// can be altered by setting certain shell variables. These may be set temporarily when starting zsh like this: \ ``` % BATTERY=1 zsh Or by setting them permanently in **zshrc.pre** (See AUXILIARY FILES below). : **BATTERY** If set to a value greater than zero and //acpi// installed, //grmlzshrc// will put the battery status into the right hand side interactive prompt. = FEATURE DESCRIPTION = This is an in depth description of non-standard features implemented by //grmlzshrc//. == DIRSTACK HANDLING == The dirstack in //grmlzshrc// has a persistent nature. It is stored into a file each time zsh's working directory is changed. That file can be configured via the **DIRSTACKFILE** variable and it defaults to **~/.zdirs**. The **DIRSTACKSIZE** variable defaults to **20** in this setup. The **DIRSTACKFILE** is loaded each time zsh starts, therefore freshly started zshs inherit the dirstack of the zsh that most recently updated **DIRSTACKFILE**. == DIRECTORY BASED PROFILES == If you want certain settings to be active in certain directories (and automatically switch back and forth between them), this is what you want. \ ``` zstyle ':chpwd:profiles:/usr/src/grml(|/|/*)' profile grml zstyle ':chpwd:profiles:/usr/src/debian(|/|/*)' profile debian ``` When that's done and you enter a directory that matches the pattern in the third part of the context, a function called chpwd_profile_grml, for example, is called (if it exists). If no pattern matches (read: no profile is detected) the profile is set to 'default', which means chpwd_profile_default is attempted to be called. A word about the context (the ':chpwd:profiles:*' stuff in the zstyle command) which is used: The third part in the context is matched against **$PWD**. That's why using a pattern such as /foo/bar(|/|/*) makes sense. Because that way the profile is detected for all these values of **$PWD**: \ ``` /foo/bar /foo/bar/ /foo/bar/baz ``` So, if you want to make double damn sure a profile works in /foo/bar and everywhere deeper in that tree, just use (|/|/*) and be happy. The name of the detected profile will be available in a variable called 'profile' in your functions. You don't need to do anything, it'll just be there. Then there is the parameter **$CHPWD_PROFILE** which is set to the profile, that was active up to now. That way you can avoid running code for a profile that is already active, by running code such as the following at the start of your function: \ ``` function chpwd_profile_grml() { [[ ${profile} == ${CHPWD_PROFILE} ]] && return 1 ... } ``` The initial value for **$CHPWD_PROFILE** is 'default'. === Signaling availabily/profile changes === If you use this feature and need to know whether it is active in your current shell, there are several ways to do that. Here are two simple ways: a) If knowing if the profiles feature is active when zsh starts is good enough for you, you can put the following snippet into your //.zshrc.local//: \ ``` (( ${+functions[chpwd_profiles]} )) && print "directory profiles active" ``` b) If that is not good enough, and you would prefer to be notified whenever a profile changes, you can solve that by making sure you start **every** profile function you create like this: \ ``` function chpwd_profile_myprofilename() { [[ ${profile} == ${CHPWD_PROFILE} ]] && return 1 print "chpwd(): Switching to profile: $profile" ... } ``` That makes sure you only get notified if a profile is **changed**, not everytime you change directory. === Version requirement === This feature requires zsh //4.3.3// or newer. == ACCEPTLINE WRAPPER == == PROMPT == == GNU/SCREEN STATUS SETTING == == PERSISTENT HISTORY == = REFERENCE = == KEYBINDINGS == == SHELL FUNCTIONS == //grmlzshrc// comes with a wide array of defined shell functions to ease the user's life. : urlencode() Takes a string as its first argument and prints it RFC 2396 URL encoded to standard out. = AUXILIARY FILES = This is a set of files, that - if they exist - can be used to customize the behaviour of //grmlzshrc//. : .zshrc.pre Sourced at the very beginning of //grmlzshrc//. Among other things, it can be used to permantenly change //grmlzshrc//'s STARTUP VARIABLES (see above): \ ``` # show battery status in RPROMPT BATTERY=1 # always load the complete setup, even for root GRML_ALWAYS_LOAD_ALL=1 ``` : .zshrc.local Sourced right before loading //grmlzshrc// is finished. There is a global version of this file (/etc/zsh/zshrc.local) which is sourced before the user-specific one. = INSTALLATION ON NON-DEBIAN SYSTEMS = = CONTRIBUTING = If you want to help to improve grml's zsh setup, clone the grml-etc-core repository from git.grml.org: \ ``` % git clone git://git.grml.org/grml-etc-core.git Make your changes, commit them; use '**git format-patch**' to create a series of patches and send those to the following address via '**git send-email**': \ ``` grml-etc-core@grml.org Doing so makes sure the right people get your patches for review and possibly inclusion. = AUTHOR = This manpage was written by Frank Terbeck . = COPYRIGHT = Copyright (c) 2009, grml project This manpage is distributed under the terms of the GPL version 2. Most parts of grml's zshrc are distributed under the terms of GPL v2, too, except for **accept-line()** and **vcs_info()**, which are distributed under the same conditions as zsh itself (which is BSD-like).