GRMLZSHRC(5)
π
grmlzshrc β the GRMLZSHRC(5) manual, but make it a whole vibe π
β¨ NAME β¨
grmlzshrc β Grmlβs zsh setup ππ
πΈ SYNOPSIS πΈ
zsh [options]...
π¦ DESCRIPTION π¦
Okay so the Grml project ships a pretty exhaustive interactive setup β weβre calling it grmlzshrc all through this doc β for the amazing unix shell zsh (http://zsh.sourceforge.net). This is literally the reference manual for that setup. β¨
To use grmlzshrc, you need at least version 5.1 of zsh. No cap.
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).
Users may want to keep an up-to-date version of the setup (possibly from the git-sources) in ~/.zshrc. If that happens on a system where the global zshrc is also a grmlzshrc (but possibly an older one), you can inhibit loading the global version by doing:
echo setopt no_global_rcs >> ~/.zshenv
Note: this will disable ANY global files, except for the global zshenv file. Like, absolutely any. π
π 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:
% GRML_DISPLAY_BATTERY=1 zsh
Or by setting them permanently in zshrc.pre (See AUXILIARY FILES below).
BATTERY
Deprecated. Use GRML_DISPLAY_BATTERY instead.
COMMAND_NOT_FOUND
A non zero value activates a handler, which is called when a command can not be found. The handler is defined by GRML_ZSH_CNF_HANDLER (see below).
GRML_COMP_CACHING
If set to yes (the default), the setup will enable zshβs completion caching mechanism, with the caching data being placed into $GRML_COMP_CACHE_DIR.
GRML_COMP_CACHE_DIR
This defines where zshβs completion caching data will be placed, if $GRML_COMP_CACHING is active. The default is ${ZDOTDIR:-$HOME}/.cache. The setup will ensure the directory exists before attempting to use it.
GRML_DISPLAY_BATTERY
If set to a value greater than zero, grmlzshrc will put the battery status into the right hand side interactive prompt. Supported OSes are GNU/Linux, FreeBSD, OpenBSD and Darwin. πβ¨
GRML_ZSH_CNF_HANDLER
This variable contains the handler to be used by COMMAND_NOT_FOUND (see above) and defaults to "/usr/share/command-not-found/command-not-found".
GRML_NO_APT_ALIASES
A non-empty value inhibits the definition of apt-specific short aliases, such as ag, agi, ati etc.
GRML_NO_SMALL_ALIASES
A non-empty value inhibits the definition of 2-letter aliases such as da. ls, ll, la and other common ls-related aliases are exempt from this, as are the aliases inhibited by GRML_NO_APT_ALIASES.
GRMLSMALL_SPECIFIC
Set this to zero to remove items in zsh config, which do not work in grml-small.
HISTFILE
Where zsh saves the history. Default: ${HOME}/.zsh_history.
HISTSIZE
Number of commands to be kept in the history. Default: 5000
MAILCHECK
Sets the frequency in seconds for zsh to check for new mail. Defaults to 30. A value of zero turns off checking.
NOCOR
Non zero values deactivate automatic correction of commands.
NOETCHOSTS
Non zero values deactivate parsing of "/etc/hosts" disabling host completion using fileβs contents.
NOMENU
If set to zero (default), allows selection from a menu, if there are at least five possible options of completion.
NOPRECMD
A non zero value disables precmd and preexec commands. These are functions that are run before every command (setting xterm/screen titles etc.).
REPORTTIME
Show time (user, system and cpu) used by external commands, if they run longer than the defined number of seconds (default: 5).
SAVEHIST
Number of commands to be stored in ${HISTFILE}. Default: 10000
watch
As in tcsh(1) an array of login/logout events to be reported by the shell builtin "log". For details see zshparam(1). Defaults to (notme root).
ZSH_NO_DEFAULT_LOCALE
Import "/etc/default/locale", if set to zero (default).
ZSH_PROFILE_RC
A non zero value causes shell functions to be profiled. The results can be obtained with the zprof builtin command (see zshmodules(1) for details).
COMPDUMPFILE
Specifies the location of the completion dump file. Default: $HOME/.zcompdump.
π GRML-ZSHRC SPECIFIC STYLES π
Styles are a context sensitive configuration mechanism included with zsh. The shell uses it extensively in sub-systems like the completion and the VCS info system. It lives outside of the classic shell variable namespace, so it avoids polluting it. New functionality in grmlβs zshrc will likely use styles instead of variables. Some features of the setup (like the directory stack handling) already use styles. Those styles are documented with the specific features. This section documents more general styles. π«Ά
Context: :grml:completion:compinit
This context revolves around the zshrcβs compinit function call, that initialises zshβs function based completion system.
arguments
This style allows the injection of arguments to the command line that is used to run compinit. It is a list style and its default is the empty list. Using this style, itβs possible to add -i to compinit in order to disable compaudit.
zstyle ':grml:completion:compinit' arguments -i
Only do this, if you know what sort of security checks are disabled if compaudit is not active and if thatβs acceptable with your specific setup. Like, fr fr, be careful. π₯
This style has to be set at the point that Grmlβs zshrc runs compinit. A possible way to achieve this is to set it in ~/.zshrc.pre (see AUXILIARY FILES below for details).
π₯ 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.
If you would like to disable the persistent dirstack feature altogether, you can do that by setting the boolean enable style to false in the right context (the default is true):
zstyle ':grml:chpwd:dirstack' enable false
It is possible to apply a filter to the names of directories that will be committed to the persistent dirstack file. There are two ways to configure this filter: A general function based filter and a pattern based filter. Both are setup via styles in the ':grml:chpwd:dirstack' context.
To use a function based filter set the filter style for that context to the name of a function to call every time a directory name is to be added to the persistent dirstack. If the functionβs return value signals success (ie. return value "0"), the directory name is filtered out and not added to the persistent stack. Example:
function my_dirstack_filter() { [[ $1 == /tmp(|/*) ]] }
zstyle ':grml:chpwd:dirstack' filter my_dirstack_filter
The pattern based filter uses a list of patterns passed to the exclude style in the aforementioned context. Each pattern is tested and the first that matches will keep the directory name from being added to the persistent stack. If none of the patterns matches, the name is added. example:
zstyle ':grml:chpwd:dirstack' exclude "/tmp(|/*)" "$HOME/tmp(|/*)"
The function based filter is more general, the pattern based filter easier to set up. If both filter variants are used at the same time, the function based filter will be executed before the pattern based one.
If you would like to apply your filters while loading the persistent dirstack file, set the filter-on-load boolean style (the default is false):
zstyle ':grml:chpwd:dirstack' filter-on-load true
Setting the filter-on-load and enable styles needs to be done in ".zshrc.pre" because the styles need to be set when the main setup is executing! The other styles do not have this limitation, but enabling the system as well as the initial filtering will obviously be done using settings and filters that are configured at that point.
With respect to filter-on-load, the rule of thumb is: If you want to filter on load, setup everything in ".zshrc.pre" otherwise ".zshrc.local" works just as well.
Directory-based Profiles
If you need to perform certain actions each time you enter certain directory-trees, this is the feature you are looking for. ποΈβ¨
Initialisation
To initialise the system, you need to call the function chpwd_profiles at some point in your zshrc.local; preferably after you configured the system. The configuration of the system is described further below.
If you need to do initialisations the first time chpwd_profiles is called (which should be in your configuration file), you can do that in a function called "chpwd_profiles_init". That function needs to be defined before chpwd_profiles is called for this to work.
During the first call of chpwd_profiles (and therefore all its profile functions) the parameter $CHPWD_PROFILES_INIT exists and is set to 1. In all other cases, the parameter does not exist at all.
Styles and Profile-names
To store its configuration, the system uses functions and styles (zshβs context sensitive configuration system), such as this:
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.
Controlling Profile Execution β¨
Okay so during its initialisation run, the system creates a parameter $CHPWD_PROFILE, and it's set to the profile that's currently active (the default value is "default"). That way you can dodge running code for a profile that's already active β just put something like this at the start of your function:
function chpwd_profile_grml() {
[[ ${profile} == ${CHPWD_PROFILE} ]] && return 1
...
}
If you already know you're gonna do that literally every single time for each and every directory-profile function you ever write, you can also set the re-execute style to false β it only defaults to true for backwards compatibility β like this:
zstyle ':chpwd:profiles:*' re-execute false
Signaling availabily/profile changes π«Ά
If you use this feature and need to know whether it's active in your current shell, there are several ways to check. Here are two simple ones:
- a) If knowing whether the profiles feature is active when zsh starts is good enough for you, use this snippet:
(( ${+functions[chpwd_profiles]} )) && print "directory profiles active"
- b) If that's not good enough and you'd rather be notified whenever a profile changes, make sure every profile function you create starts 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. (To avoid this, you can also set the newer re-execute style like described further above instead of doing the test on top of the function. iykyk.)
Leaving Profiles π
When the system switches from one profile to another, it executes a function named chpwd_leave_profile_<PREVIOUS-PROFILE-NAME>() before calling the profile-function for the new profile. No cap, that's the lil goodbye moment.
Accept-Line wrapper π
The accept-line widget is the one that's taking action when the return key is hit. grmlzshrc uses a wrapper around that widget, and the wrapper adds new functionality.
This wrapper is configured via styles. That means you issue commands that look like:
zstyle 'context' style value
The context namespace we're using is 'acceptline'. That means the actual context for your commands looks like:
':acceptline:<subcontext>'
Where <subcontext> is one of: default, normal, force, misc or empty.
Recognized Contexts π
defaultβ This is the value the context is initialized with. Thecompwarnfmtand//rehashstyles are looked up in this context.normalβ If the first word in the command line is either a command, alias, function, builtin or reserved word, you are in this context.forceβ This is the context that's used if you hit enter again, after being warned about the existence of a_completionfor the non-existing command you entered.emptyβ This is the context you're in if the command line is empty or only consists of whitespace.miscβ This context is in effect if you entered something that does not match any of the above. (e.g.: variable assignments).
Available Styles π
nocompwarnβ If you set this style totrue, the warning about non existent commands, for which completions exist, will not be issued. (Default:false)compwarnfmtβ The message that is displayed to warn about the_completionissue. (default:'%c will not execute and completion %f exists.')%cis replaced by the command name,%fby the completionβs name.rehashβ If this is set, weβll force rehashing, if appropriate. (Defaults totruein grmlzshrc).actionsβ This can be a list of wigdets to call in a given context. If you need a specific order for these to be called, name them accordingly. The default value is an empty list.default_actionβ The name of a widget that is called after the widgets from'actions'. By default, this will be'.accept-line'(which is the built-inaccept-linewidget).call_defaultβ Iftruein the current context, call the widget in the'default_action'style. (The default istruein all contexts.)
Prompt</prompt> π¦
The grmlzshrc now supplies three prompt themes compatible with zshβs promptinit system. The three themes are called grml, grml-large and grml-chroot.
By default, grml is used, unless $GRMLPROMPT is set to a value larger than zero, in which case grml-large is used. Lastly, if $GRML_CHROOT is non-empty, grml-chroot is used.
As usual with promptinit themes, the user may switch to a different theme using the prompt utility:
prompt grml-large
That will use the grml-large prompt theme.
The themes are highly customisable. The main source of documentation about customisation is the main grml themeβs doc-string, which is available via the following command:
prompt -h grml
The other themes also come with doc-strings, but the main themeβs is the canonical reference about all of them.
This feature requires version 4.3.7 of the shell. Older versions will use the classic grml prompt as a fallback.
A note to people who like customisation: if you are not using a prompt theme for your customisation, but youβre either statically setting $PS1 (or $PROMPT) or youβre constructing one of those variables in zshβs precmd() function, make sure you are turning zshβs prompt theme system off before doing so. A correct example customisation could look like this:
# Turn the prompt system off:
prompt off
# Customise the prompt yourself:
PS1='%~ %# '
You also add your own tokens by using the grml_theme_add_token() function. Call the function without arguments for detailed documentation about that procedure.
GNU screen Status π
grmlzshrc sets screenβs hardstatus lines to the currently running command or 'zsh' if the shell is idling at its prompt. If the current working directory is inside a repository unter version control, screen status is set to: 'zsh: <repository name>' via zshβs vcs_info.
Persistent History β
If you got commands you consider important enough to be included in every shellβs history, you can put them into $GRML_IMPORTANT_COMMANDS (which defaults for backward compatibility to ~/.important_commands) and they will be available via the usual history lookup widgets.
REFERENCE π
Environment Variables π
grmlzshrc sets some environment variables, which influence the behaviour of applications.
COLORTERMβ Set to"yes". Some applications read this to learn about properties of the terminal they are running in.EDITORβ If not already set, sets the default editor. Falls back tovi(1), ifvim(1)is not available.LESS_TERMCAP_*β Some environment variables that add colour support toless(1)for viewing man pages. Seetermcap(5)for details.MAILβ The mailbox file for the current user is set to/var/mail/$USER, if not already set otherwise.PAGERβ Setless(1)as default pager, if not already set to something different.
Options π
Apart from zshβs default options, grmlzshrc sets some options that change the behaviour of zsh. Options that change Z-shellβs default settings are marked by <grml>. But note that zshβs defaults vary depending on its emulation mode (csh, ksh, sh, or zsh). For details, see zshoptions(1).
append_historyβ Zsh sessions that use grmlzshrc will append their history list to the history file, rather than replace it. Thus, multiple parallel zsh sessions will all have the new entries from their history lists added to the history file, in the order that they exit. The file will still be periodically re-written to trim it when the number of lines grows20%beyond the value specified by$SAVEHIST.auto_cd<grml>β If a command is issued that canβt be executed as a normal command, and the command is the name of a directory, perform thecdcommand to that directory.auto_pushd<grml>β Makecdpush the old directory onto the directory stack.completeinword<grml>β If the cursor is inside a word, completion is done from both ends; instead of moving the cursor to the end of the word first and starting from there.extended_glob<grml>β Treat the'#','~'and'^'characters as active globbing pattern characters.extended_history<grml>β Save each commandβs beginning timestamp (in seconds since the epoch) and the duration (in seconds) to the history file.hash_list_allβ Whenever a command completion is attempted, make sure the entire command path is hashed first. This makes the first completion slower.histignorespace<grml>β Remove command lines from the history list when the first character on the line is a space, or when one of the expanded aliases contains a leading space. Note that the command lingers in the internal history until the next command is entered before it vanishes.longlistjobs<grml>β List jobs in long format by default.nobeep<grml>β Avoid to beep on errors in zsh command line editing (zle).noglobdotsβ A wildcard character never matches a leading'.'.nohup<grml>β Do not send the hangup signal (HUP:1) to running jobs when the shell exits.nonomatch<grml>β If a pattern for filename generation has no matches, do not print an error and leave it unchanged in the argument list. This also applies to file expansion of an initial~or=.notifyβ Report the status of background jobs immediately, rather than waiting until just before printing a prompt.pushd_ignore_dups<grml>β Donβt push multiple copies of the same directory onto the directory stack.share_history<grml>β As each line is added to the history file, it is checked to see if anything else was written out by another shell, and if so it is included in the history of the current shell too. Using!-style history, the commands from the other sessions will not appear in the history list unless you explicitly type the"history"command. This option is activated for zsh versions>= 4, only.
Keybindings πΉ
Apart from zshβs default key bindings, grmlzshrc comes with its own set of key bindings. Note that bindings like ESC-e can also be typed as ALT-e on PC keyboards.
ESC-eβ Edit the current command buffer in your favourite editor.ESC-vβ Deletes a word left of the cursor; seeing/as additional word separator.CTRL-x-1β jumps right after the first word. β¨CTRL-x-M()β creates a directory under the cursor or under the selected area. To select an area, pressctrl-@and use the cursor. Use case: you typemv abc ~/testa/testb/testc/and remember that the directory does not exist yet β pressCTRL-xMand problem solved. πCTRL-x-pβ searches the last occurrence of a string before the cursor in the command history.CTRL-x-zβ displays help on keybindings and the zsh line editor. Press consecutively to page through content.CTRL-zβ brings a job that got suspended withCTRL-zback to the foreground.
π Customisation
To customise keybindings, you can just use zshβs bindkey utility. But lowkey important: if you plan to use the zle-line-init or zle-line-finish hooks yourself, make sure you call these functions in the respective hook:
zle-line-init:zle-smkxzle-line-finish:zle-rmkx
This is required so the keybindings set up by grmlzshrc work. The reason is to turn the terminal into the right mode while zshβs line editor (zle) is running. That lets us query terminfo about escape sequences for special keys and thus simplify and generalise our keybinding section.
π§° Shell Functions
grmlzshrc comes with a wide array of defined shell functions to ease the userβs life.
accessed()β lists files in the current directory that have been accessed within the last N days. N is an integer passed as the first and only argument. If no argument is specified, N is set to1.any()β lists processes matching the given pattern.bk()β simple backup management of a file or directory using standard unix programs. The target file name is the original name plus a time stamp attached. Symlinks and file attributes like mode, ownership and timestamps are preserved.cdt()β creates a temporary directory usingmktemp. Then changes the current working directory to it. You can optionally provide a prefix which will result in e.g./tmp/PREFIX.XXXXXXX.changed()β lists files in the current directory that have been changed within the last N days. N is an integer passed as the first and only argument. If no argument is specified, N is set to1.check_com()β returns true if the given command exists either as a program, function, alias, builtin or reserved word. If the option-cis given, it only returns true if the command is a program.cl()β changes the current directory to the one supplied by argument and lists the files in it, including file names starting with".".dchange()β shows the changelog of the given package in$PAGER.dcopyright()β shows the copyright of the given package in$PAGER.debian2hd()β tells the user to usegrml-debootstrapif she wants to install debian to harddisk.deswap()β a trick from$LINUX-KERNELSOURCE/Documentation/power/swsusp.txt. It brings back interactive responsiveness after suspend when the system is swapping heavily.dnews()β shows the NEWS file for the given package in$PAGER.dreadme()β shows the README file for the given package in$PAGER.edalias()β edits the given alias.edfunc()β edits the given shell function.freload()β reloads an autoloadable shell function (seeautoloadinzshbuiltins(1)).grml_status_features()β prints a summary of features the grml setup is trying to load. The result of loading a feature is recorded. This function lets you query the result. It takes one argument:-hor--helpto display this help text,""to display a list of all successfully loaded features,-for a list of all features that failed to load, and-to show a list of all features with their statuses. Any other word is considered to be a feature and prints its status. The default mode is+-.grml_vcs_info_toggle_colour()β toggles between coloured and uncoloured formats invcs_infoconfiguration. This is useful with prompts that break if colour codes are invcs_infoformat expansions (like theclintprompt and every other prompt that uses%vto expand the contents of$vcs_into_msg_0_). If you are using customisedvcs_infoformats, you shouldnβt be using this function, since it will set all formats to grmlβs default values (either coloured or plain) again.hgdi()β use GNU diff with options-ubwdfor mercurial.hgstat()β displays diffstat between the revision given as argument and tip (no argument means last revision).hidiff()β outputs highlighted diff; needshighstring(1).isdarwin()β returns true if running on darwin, else false.isfreebsd()β returns true if running on FreeBSD, else false.isgrml()β returns true if running on a grml system, else false.isgrmlcd()β returns true if running on a grml system from a live cd, else false.isgrmlsmall()β returns true if run on grml-small, else false.islinux()β returns true if running on Linux, else false.isopenbsd()β returns true if running on OpenBSD, else false.isutfenv()β returns true if run within an utf environment, else false.mkcd()β creates a directory including parent directories if necessary. Then changes the current working directory to it.modified()β lists files in the current directory that have been modified within the last N days. N is an integer passed as the first and only argument. If no argument is specified, N is set to1.nt()β a helper function for the"e"glob qualifier to list all files newer than a reference file. Example usages:
% NTREF=/reference/file
% ls -l *(e:nt:)
% # Inline:
% ls -l *(e:'nt /reference/file':)
profile()β runs a command in zsh with profiling enabled (see startup variableZSH_PROFILE_RCabove).salias()β creates an alias with sudo prepended if$EUIDis not zero. Runsalias -hfor details.simple-extract()β tries to uncompress/unpack the given files with the appropriate programs. If an URI starting withhttps,httporftpis provided,simple-extracttries to download and then uncompress/unpack the file. The choice is made along the filename ending.simple-extractwill not delete the original archive (even on.gz,.bz2or.xz) unless you use the-doption.sll()β prints details of symlinks given as arguments.ssl-cert-fingerprintsβ prints the SHA512, SHA256, SHA1 and MD5 digest of a x509 certificate. The first and only parameter must be a file containing a certificate. Use/dev/stdinas file if you want to pipe a certificate to these functions.ssl-cert-infoβ prints all information of a x509 certificate including the SHA512, SHA256, SHA1 and MD5 digests. The first and only parameter must be a file containing a certificate. Use/dev/stdinas file if you want to pipe a certificate to this function.ssl-cert-sha512(),ssl-cert-sha256(),ssl-cert-sha1(),ssl-cert-md5()β prints the SHA512, SHA256, SHA1 respective MD5 digest of a x509 certificate. The first and only parameter must be a file containing a certificate. Use/dev/stdinas file if you want to pipe a certificate to this function.Start(), Restart(), Stop(), Force-Reload(), Reload()β functions for controlling daemons. Example usage:
% Restart ssh
trans()β translates a word from german to english (-D) or vice versa (-E).uchange()β shows upstreams changelog of a given package in$PAGER.vim()β wrapper forvim(1). It tries to set the title and hands vim the environment variableVIM_OPTIONSon the command line. So the user may define command line options she always wants in her.zshrc.local.whatwhen()β searches the history for a given pattern and lists the results by date. The first argument is the search pattern. The second and third ones are optional and denote a search range (default:-100).xcat()β tries tocat(1)file(s) given as parameter(s). Always returns true.xsource()β tries to source the file(s) given as parameter(s). Always returns true. Seezshbuiltins(1)for a detailed description of the source command.xtrename()β changes the title of an xterm window from withinscreen(1). Run without arguments for details.zrcautoload()β wrapper around theautoloadbuiltin. Loads the definitions of functions from the file given as argument. Searches$fpathfor the file.zrclocal()β sources/etc/zsh/zshrc.localand${HOME}/.zshrc.local. These are the files where own modifications should go. See alsozshbuiltins(1)for a description of the source command.
π·οΈ Aliases
grmlzshrc comes with a wide array of predefined aliases to ease the userβs life. A few aliases (like those involving grep or ls) use the option --color=auto for colourizing output. That option is part of GNU implementations of these tools, and will only be used if such an implementation is detected.
acp (apt-cache policy)β with no arguments prints out the priorities of each source. If a package name is given, it displays detailed information about the priority selection of the package.acs (apt search)β searches debian package lists for the regular expression provided as argument. The search includes package names and descriptions. Prints out name and short description of matching packages.acsh (apt show)β shows the package records for the packages provided as arguments.adg (apt dist-upgrade)β performs an upgrade of all installed packages. Also tries to automatically handle changing dependencies with new versions of packages. As this may change the install status of (or even remove) installed packages, it is potentially dangerous to use dist-upgrade; invoked by sudo, if necessary. β οΈag (apt upgrade)β downloads and installs the newest versions of all packages currently installed on the system. Under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first (seeaubelow); run by sudo, if necessary.agiβapt install. Downloads and installs or upgrades whatever packages you hand it on the command line. Slap a hyphen onto a package name and that package gets removed if it's currently installed β like, spicy. Similarly you can stick a plus sign on to mark a package for installation, which is lowkey useful when you wanna override the decisions apt's conflict resolution system made for you. Want one specific version? Follow the package name with an equals sign and the version, and it'll go find and select exactly that one. Or pick a specific distribution by following the package name with a slash and the version of the distribution, or the Archive name (stable,testing,unstable). Gets invoked bysudoif your user id is not0. πatiβaptitude install. Aptitude is that terminal-based package manager with a command line mode that's basically apt's sibling (peepagiabove); invoked bysudo, if necessary.auβapt update. Resynchronizes the package index files from their sources β the indexes of available packages get fetched from the location(s) listed in/etc/apt/sources.list. Fr fr, always run an update before an upgrade or dist-upgrade. Run bysudo, if necessary.afsβapt-file search.apt-fileis a command line tool for searching files contained in packages for the APT packaging system. You can search for which package a file is in, or list the contents of a package, without installing it or even fetching it. Iconic behaviour honestly.daβdu -sch. Prints the summarized disk usage of the arguments plus a grand total, all in human readable format. πdbpβdpkg-buildpackage. Builds binary or source packages from sources (see:dpkg-buildpackage(1)).debs-by-sizeβgrep-status -FStatus -sInstalled-Size,Package -n "install ok installed" | paste -sd " \n" | sort -rn. Prints installed Packages sorted by size, descending. Biggest offenders first, bestie. πdirβls -lSrah. Lists files (dot files included!) sorted by size with the biggest one last, in long and human readable output format.geβgrep-excuses. Searches the testing excuses files for a specific maintainer (see:grep-excuses(1)).grepβgrep --color=auto. Shows grep output in nice colors, if available. Aesthetic and functional. πgrml-versionβcat /etc/grml_version. Prints the version of the running grml.insecscpβscp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null".scpwith possible man-in-the-middle attack enabled. This is convenient if the target host key changes frequently β say, on virtualized test- or development-systems. To be used only inside trusted networks, of course.
β οΈ Bestie, notice the insec in the name? That's not cute branding, that's a literal security downgrade. Only inside networks you actually trust. π
insecsshβssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null".sshwith possible man-in-the-middle attack enabled (for an explanation, peepinsecscpabove).help-zshglobβH-Glob(). Runs the functionH-Glob()to expand or explain wildcards. Wildcards explained to you, personally. β¨lβls -l --color=auto. Lists files in long output format with an indicator for filetype appended to the filename. If your terminal supports it, with colored output.laβls -la --color=auto. Lists files in long colored output format, including file names starting with..ladβls -d .*(/). Lists the dot directories (not their contents) in the current directory. πlhβls -hAl --color=auto. Lists files in long and human readable output format in nice colors, if available. Includes file names starting with.β except.and.., obviously.llβls -l --color=auto. Lists files in long colored output format.llogβ$PAGER /var/log/syslog. Opens syslog in your pager.lsβls -C --color=auto. Lists the directory, entries listed by columns, with an indicator for file type appended to each file name. Plus the output is colored, if the terminal supports it.lsaβls -a .*(.). Lists dot files in the current working directory.lsbigβls -flh *(.OL[1,10]). Displays the ten biggest files (long and human readable output format).lsdβls -d *(/)). Shows directories. (No, not that kind of lsd, bestie. π)lseβls -d *(/^F). Shows empty directories.lslβls -l *(@). Lists symbolic links in the current directory. π¦lsnewβls -rl *(D.om[1,10]). Displays the ten newest files (long output format).lsnewdirβls -rthdl *(/om[1,10]) .*(D/om[1,10]). Displays the ten newest directories and ten newest.directories.lsoldβls -rtlh *(D.om[1,10]). Displays the ten oldest files (long output format).lsolddirβls -rthdl *(/Om[1,10]) .*(D/Om[1,10]). Displays the ten oldest directories and ten oldest.directories.lssβls -l *(s,S,t). Lists files in the current directory that have the setuid, setgid or sticky bit set.lssmallβls -Srl *(.oL[1,10]). Displays the ten smallest files (long output format).lswβls -ld *(R,W,X.^ND/). Displays all files which are world readable and/or world writable and/or world executable (long output format). A whole vibe check on your permissions, ngl.lsxβls -l *(*)). Lists only executable files.mdstatβcat /proc/mdstat. Lists all active md (i.e. linux software raid) devices with some info about them.mqβhg -R $(readlink -f $(hg root)/.hg/patches). Executes the commands on the versioned patch queue from the current repository.rmcdirβ'cd ..; rmdir $OLDPWD || cd $OLDPWD.rmdirthe current working directory. Sneaky but it works. πscreenβscreen -c file. Unless$HOME/.screenrcexists, start a screen session with/etc/grml/screenrcas the config file. If we detect screen to be an older release, start the session with/etc/grml/screenrc_v4instead.suβsudo su. If the user is running a Grml live system, don't ask for any password when she wants a root shell.tlogβtail --follow=name /var/log/syslog. Prints syslog continuously (seetail(1)).upβaptitude update ; aptitude safe-upgrade. Performs a system update followed by a system upgrade using aptitude; run bysudo, if necessary. Seeauandagabove.url-quoteβautoload -U url-quote-magic ; zle -N self-insert url-quote-magic. After calling it, characters of URLs as you type get automatically escaped, if necessary, to protect them from the shell. Lowkey a lifesaver. π«Ά$(uname -r)-rebootβkexec -l --initrd=/boot/initrd.img-"$(uname -r)" --command-line=\"$(cat /proc/cmdline)\" /boot/vmlinuz-"$(uname -r)". Reboots usingkexec(8)and thus reduces boot time by skipping hardware initialization of BIOS/firmware. Speedy reboots, slay. π₯...βcd ../../. Changes the current directory two levels higher. Yep, three literal dots. It's giving convenience.
π AUXILIARY FILES π
This is a set of files that β if they exist β can be used to customize the behaviour of grmlzshrc. Conditional queens only. π
.zshrc.preβ Sourced at the very beginning ofgrmlzshrc. Among other things, it can be used to permanently changegrmlzshrc'sSTARTUP VARIABLES(see above):
# show battery status in RPROMPT
GRML_DISPLAY_BATTERY=1
# always load the complete setup, even for root
GRML_ALWAYS_LOAD_ALL=1
.zshrc.localβ Sourced right before loadinggrmlzshrcis finished. There's a global version of this file (/etc/zsh/zshrc.local) which is sourced before the user-specific one. β¨.zdirsβ Directory listing for persistent dirstack (see above)..important_commandsβ List of commands, used by persistent history (see above).
π INSTALLATION ON NON-DEBIAN SYSTEMS π
On Debian systems (http://www.debian.org) β and possibly Ubuntu (http://www.ubuntu.com) and similar systems β it is very easy to get grmlzshrc via grml's .deb repositories. Chef's kiss. π€
On non-Debian systems that is not an option, but all is not lost:
% wget -O .zshrc http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc
If you would also like to get separate function files (which you can put into your $fpath), you can browse and download them at:
http://git.grml.org/?p=grml-etc-core.git;a=tree;f=usr_share_grml/zsh;hb=HEAD
π·οΈ ZSH-REFCARD TAGS π·οΈ
okay bestie, real talk β if you ever peek at grmlzshrc's actual code you're gonna see some weird looking comments in there and think "who hurt you π". But no, they're there on purpose, I promise. grml's zsh-refcard gets generated automatically from the contents of the actual configuration file. The thing is, the generator needs a lil extra info about which comments and which lines of code to pay attention to (and what to do with them). So we sprinkle in tags. It's giving β¨annotatedβ¨.
Here's what they all mean:
The full tag list (comment types) we use:
#a#β the next line contains an important alias that should go into the grml-zsh-refcard. (placement tag:@@INSERT-aliases@@)#f#β the next line contains the beginning of an important function. (placement tag:@@INSERT-functions@@)#v#β the next line contains an important variable. (placement tag:@@INSERT-variables@@)#k#β the next line contains an important keybinding. (placement tag:@@INSERT-keybindings@@)#d#β hashed directories list generation:startmarks the start of a list of'hash -d'definitions,endmarks its end. (placement tag:@@INSERT-hasheddirs@@)#A#β abbreviation expansion list generation:startmarks the beginning of abbreviations,endmarks their end.
Lines within this section that end in '#d .*' provide extra documentation to be included in the refcard. (placement tag: @@INSERT-abbrev@@)
#m#β this tag lets you manually generate refcard entries for code lines that are hard or straight-up impossible to parse. Iconic, honestly.
Example, bestie:
#m# k ESC-h Call the run-help function
That would add a refcard entry in the keybindings table for 'ESC-h' with the given comment. Slay.
So the syntax is:
#m# <section> <argument> <comment>
#o#β this tag lets you insert entries to the'other'hash. Generally you should not use this one. It exists for the things that genuinely can't be done easily any other way. (placement tag:@@INSERT-other-foobar@@)
All of these tags (except for m and o, note π
) take two arguments β the first one within the tag, the other one after the tag:
#<tag><section># <comment>
Where <section> is really just a number, and those numbers are defined by the @secmap array on top of 'genrefcard.pl'. Why numbers instead of names? Because for the poor reader, the tag shouldn't look too different from a regular comment β for zsh, it's a regular comment anyway. iykyk.
The numbers mean the following:
0default1system2user3debian4search5shortcuts6services
So like, the following will add an entry to the 'functions' table in the 'system' section, with a (hopefully) descriptive comment:
#f1# Edit an alias via zle
edalias() {
It'll then show up in the @@INSERT-aliases-system@@ replacement tag that lives in 'grml-zsh-refcard.tex.in'. If you omit the section number, the 'default' section is assumed. Also, in 'grml-zsh-refcard.tex.in', @@INSERT-aliases@@ is exactly the same as @@INSERT-aliases-default@@. And if you want a list of all aliases, for example, use @@INSERT-aliases-all@@. Obsessed with the flexibility ngl π«Ά
π CONTRIBUTING π
Wanna help make grml's zsh setup even better? Love that for you, genuinely. 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, then 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 it this way makes sure the right people get your patches for review and possibly inclusion. Teamwork makes the dream work π
π STATUS π
This manual page is the reference manual for grmlzshrc.
Which means β and this is the whole point β that in contrast to the existing refcard, it should document every aspect of the setup. Every. Single. One.
Real talk though: this manual is currently not complete. If you want to help improve it, visit these pages:
http://wiki.grml.org/doku.php?id=zshrcmanualhttp://lists.mur.at/pipermail/grml/2009-August/004609.html
Contributions are highly welcome. Like, highly. Come through π
π AUTHORS π
This manpage was written by:
- Frank Terbeck
<mailto:ft@grml.org> - Joerg Woelke
<mailto:joewoe@fsmail.de> - Maurice McCarthy
<mailto:manselton@googlemail.com> - Axel Beckert
<mailto:abe@deuxchevaux.org>
π COPYRIGHT π
Copyright (c) 2009-2025 Grml project <https://grml.org/>
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(), which is distributed under the same conditions as zsh itself (which is BSD-like). Not me pointing that out at the function level π but okay, we keep the receipts.
that's the whole page, bestie β you made it to the very end π
And yes, the source/version line and the date at the bottom: this one's GRMLZSHRC(5), dated 2026-09-02. You're officially a grml zsh scholar now, no cap. Go forth and configure β¨π¦π
π¦ where this page comes from
- arch rolling: grml-zsh-config 0.20.2-1 Β· GPL2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms