The configuration framework for Zsh (by sorin-ionescu)

Prezto Alternatives

Similar projects and alternatives to prezto

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a better prezto alternative or higher similarity.

Suggest an alternative to prezto

Reviews and mentions

Posts with mentions or reviews of prezto. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-01-06.
  • Have them all with Zsh & ZI
    4 projects | | 6 Jan 2022
    Many Zsh users have their favorites like Oh My Zsh, Prezto, powerlevel10k and it is hard to get all the favorites to work simultaneously in a way you would enjoy it.
  • [Zsh4Human]I don't know how to write zstyle, even after reading wikis and blogs.
    4 projects | | 24 Dec 2021
  • Zsh Frameworks
    7 projects | | 15 Dec 2021
    Prezto. 12.5k GitHub stars. Here's the first serious fork. It began as an extremely talented programmer forking it and spending 1 whole year cleaning up Oh My Zsh's code, fixing performance issues and bugs, cleaning up the code organization and making everything a lot better. Unfortunately, Oh My Zsh's author felt like the changes made it "no longer his code", so he didn't merge it. Prezto then became its own separate project. Most of its code is rewritten and cleaned up compared to Oh My Zsh. And it has a several skilled, active maintainers.
  • A Guide to the Zsh Completion With Examples
    4 projects | | 11 Dec 2021
    Enter fullscreen mode Exit fullscreen mode

    The pattern act as a namespace. It's divided by colons : and each value between these colons have a precise meaning.

    In the case of the Zsh completion system, the context we saw earlier (what you've already typed in your command-line) is compared with this pattern. If there's a match, the style will be applied.

    Don't worry if all of that sounds confusing: bare with me, I'll give some examples soon. For now, let's look a bit closer to the zstyle patterns we can use to configure our completion system.

    See man zshcompsys for the list of styles for the completion system (search for "Standard Styles").

    General zstyle Patterns for Completion

    To configure the completion system, you can use zstyle patterns following this template:

    Enter fullscreen mode Exit fullscreen mode

    The substring separated with colons : are called components. Let's look at the ones used for the completion system in details:

    • completion - String acting as a namespace, to avoid pattern collisions with other scripts also using zstyle.
    • - Apply the style to the completion of an external function or widget.
    • - Apply the style to a specific completer. We need to drop the underscore from the completer's name here.
    • - Apply the style to a specific command, like cd, rm, or sed for example.
    • - Apply the style to the nth option or the nth argument. It's not available for many styles.
    • - Apply the style to a specific tag.

    You can think of a tag as a type of match. For example "files", "domains", "users", or "options" are tags.

    For the list of tags, see man zshcompsys (search for "Standard Tags")

    You don't have to define every component of the pattern. Instead, you can replace each of them with a star *. The more specific the pattern will be, the more precedence it will have over less specific patterns. For example:

    zstyle ':completion:*:*:cp:*' file-sort size
    zstyle ':completion:*' file-sort modification
    Enter fullscreen mode Exit fullscreen mode

    What happens if you set these styles?

    1. If you hit TAB after typing cp, the possible files matched by the completion system will be ordered by size.
    2. When you match files using the completion, they will be ordered by date of modification.

    The pattern :completion:*:*:cp:* has precedence over :completion:* because it's considered more precise.

    The * replace any character including the colon :. That's why the pattern :completion:*:*:cp:* is equivalent to :completion:*:cp:*. That said, I find the second form confusing: it's not clear what cp is. Is it a command? A function? A tag? In that case it's pretty obvious, but it's not always cp in the pattern. Personally, I always try to use the first form.

    You can run zstyle in your shell to display the styles set in your current session as well as their patterns.

    Examples of zstyles for the Zsh Completion

    All of that is quite verbose and not very self-explanatory, so let's look at more examples. Here's a simple one:

    zstyle ':completion:*' verbose yes
    Enter fullscreen mode Exit fullscreen mode

    This zstyle command is composed of:

    • A pattern: :completion:*
    • A style: verbose
    • A value: yes

    There is only one value given here, because the style verbose only accept one. But you can set more than one for some styles. Each of these values would be separated by a space. For example:

    zstyle ':completion:*:*:cp:*' file-sort modification reverse
    Enter fullscreen mode Exit fullscreen mode

    We give here two values to the style file-sort: modification (to order the matches by date of modification) and reverse (to reverse the order). As we saw before, the pattern :completion:*:*:cp:* indicates that we only set the style file-sort to the command cp.

    Let's see now a couple of styles we can set to improve our Zsh completion.

    For more zstyle, see man zshmodules (search for "zstyle").

    Useful Style for the Zsh Completion System

    I would recommend creating a new file completion.zsh somewhere and sourcing it directly in your file .zshrc as follows:

    source /path/to/my/completion.zsh
    Enter fullscreen mode Exit fullscreen mode

    Every style defined here should be called after autoloading and calling compinit. If you don't want a separate file, you can throw all this configuration into your .zshrc too.

    The Essential

    Defining the Completers

    Let's first define the completer we'll use for our completion system. Here are some interesting ones:

    • _complete - This is the main completer we need to use for our completion.
    • _approximate - This one is similar to _complete, except that it will try to correct what you've typed already (the context) if no match is found.
    • _expand_alias - Expand an alias you've typed. It needs to be declared before _complete.
    • _extensions - Complete the glob *. with the possible file extensions.

    Note that you can use _expand_alias with the keystroke CTRL+x a by default, without the need to use it as a completer. Simply type one of your alias in Zsh and try to use the keystroke.

    You need to set the zstyle completer to define the completer you want to use. The order matter: the completion system will try each of these completer one after the other. The completion stop when some matches are found or when the completer stop it by itself.

    For example, here are the completers I use:

    zstyle ':completion:*' completer _extensions _complete _approximate
    Enter fullscreen mode Exit fullscreen mode

    Since we're dabbling into the completion system, the completer _complete_help might come in handy. You can use it as a function you can call with CTRL+x h by default.

    When you're not sure why you end up with some matches and not others, you can hit CTRL+x h (for help) before completing your command. It will display some information about what the completion system will do to complete your context.

    Caching the Completion

    Using a cache for the completion can speed up some commands, like apt for example. Let's add the following in our file to enable it:

    zstyle ':completion:*' use-cache on
    zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/.zcompcache"
    Enter fullscreen mode Exit fullscreen mode

    As you might have guessed, the style cache-path allows you to set the filename and location of the cache.

    The Completion Menu

    Instead of going through each match blindly to add what you want to your command, you can use a completion menu. For that, you need to set the style menu with the value select as follows:

    zstyle ':completion:*' menu select
    Enter fullscreen mode Exit fullscreen mode

    You can also use this menu only if a precise of matches is found with select=. It's even possible to start the menu selection only if the list of matches doesn't fit the screen, by using the value select=long. Using both values select= and select=long is possible too.

    Having the values select and interactive allows you to filter the completion menu itself using the completion system. You can also configure a keystroke to switch this interactive mode when the completion menu is displayed. More on that later in this article.

    Adding the value search to the style will allow you to fuzzy-search the completion menu. Again, a keystroke can be configured to have this functionality on demand.

    Formatting The Display

    Colors and Decoration

    Let's now improve the display of our completion menu using the style format.

    Each completer can define different sequences (beginning with %) for different tags. For example:

    zstyle ':completion:*:*:*:*:descriptions' format '%F{green}-- %d --%f'
    Enter fullscreen mode Exit fullscreen mode

    As we saw quickly above, a tag is most of the time a type of match. More generally, you can see it as a type of information displayed during completion. Here, the descriptions tag is specific to the format style. It generates descriptions depending on the type of match. For example, if you have files displayed in the completion menu, the description for the tag "files" will be displayed too.

    The value of format is used for displaying these descriptions. Here, we use in the style's value the sequence %d which will be replaced by the description itself.

    Here's the result for local directories:

    Zsh format style with description for completion system

    If you're using the completer _approximate, you can set the format of the possible corrections too. For example:

    zstyle ':completion:*:*:*:*:corrections' format '%F{yellow}!- %d (errors: %e) -!%f'
    Enter fullscreen mode Exit fullscreen mode

    Here's the result:

    Zsh format style with correction for completion system

    To format messages or warnings (for example when no match is found), you can add the following:

    zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
    zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
    Enter fullscreen mode Exit fullscreen mode

    We can use the escape sequence %F %f in the style's value to use a foreground color. Here's a summary of sequences you can use:

    • %F{} %f - Change the foreground color with .
    • %K{} %k - Change the background color with .
    • %B %b - Bold.
    • %U %u - Underline.

    For example, you can create a horrible display as follows:

    zstyle ':completion:*:descriptions' format '%U%K{yellow} %F{green}-- %F{red} %BNICE!1! %b%f %d --%f%k%u'
    Enter fullscreen mode Exit fullscreen mode

    Your descriptions are now a piece of art.

    Grouping Results

    To group the different type of matches under their descriptions, you can add the following:

    zstyle ':completion:*' group-name ''
    Enter fullscreen mode Exit fullscreen mode

    Without this style, all the descriptions will be at the top and the matches at the bottom:

    Before setting the style group-name in Zsh

    With the value of this style set with an empty string, the matches will be grouped under the descriptions depending on their types:

    after setting the style group-name in Zsh

    If you're not satisfied by the order these descriptions are displayed, you can modify it too. For example:

    zstyle ':completion:*:*:-command-:*:*' group-order alias builtins functions commands
    Enter fullscreen mode Exit fullscreen mode

    Here, -command- means any word in the "command position". It means that we want the matches tagged alias to appear before builtins, functions, and commands.

    Detailed List of Files and Folders

    The style file-list can display the list of files and folder matched with more details, similar to the information you can display with ls -l.

    For example:

    zstyle ':completion:*' file-list all
    Enter fullscreen mode Exit fullscreen mode

    Here's the result:

    Before setting the style group-name in Zsh

    Colorful Completion List

    To have nice colors for your directories and file in the completion menu, you can add the style list-colors.

    zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
    Enter fullscreen mode Exit fullscreen mode

    It will set the value with the content of the environment variable LS_COLORS, normally used by the command ls --color=auto.

    You apparently need to have the module zsh/complist loaded, but it worked without it on my system. I describe a bit more the module complist later in this article.

    You can configure the colors of any completion menu even further using the environment variable ZLS_COLORS.

    To configure the colors, search man zshmodules (search "Colored completion listings").

    Smarter Completion System

    Squeezing Slashes

    By default, the completion system will expand // to /*/. For example, cd ~//Documents will be expanded to cd ~/*/Documents.

    Usually, on Unix systems, // is expanded to /. If you prefer this behavior, you can set the style squeeze-slashes to true as follows:

    zstyle ':completion:*' squeeze-slashes true
    Enter fullscreen mode Exit fullscreen mode

    Directory Stack Completion

    For the command cd, chdir and pushd, you can use a hyphen - not only for options but for a directory stack entry.

    By default, the Zsh completion system will try to complete for a directory stack entry when you hit tab after a hyphen - while using one of these commands. If you prefer completing for an option, you can set the style complete-options to true as follows:

    zstyle ':completion:*' complete-options true
    Enter fullscreen mode Exit fullscreen mode

    If you're interested to learn more about the directory stack, I described a nice way to navigate through it in this article

    Sorting Matched Files

    You can sort the files appearing in the completion menu as follows:

    zstyle ':completion:*' file-sort dummyvalue
    Enter fullscreen mode Exit fullscreen mode

    If this style is not set (or set with a dummy value like in the example above), the files will be sorted alphabetically. You can use one of these values if you prefer another ordering:

    • size - Order files by size.
    • links - Order files depending on the links pointing to them.
    • modification or date or time - Order files by date of modification.
    • access - Order files by time of access.
    • change or inode - Order files by the time of change.

    You can also add reverse to the values to reverse the order. For example:

    zstyle ':completion:*' file-sort change reverse
    Enter fullscreen mode Exit fullscreen mode

    If you add the value follow, the timestamp of the targets for symlinks will be used instead of the timestamp of the symlinks themselves.

    Completion Matching Control

    Setting the style matcher-list allows you to filter the matches of the completion with even more patterns.

    For example, you can set this style for the completion to first try the usual completion and, if nothing matches, to try a case-insensitive completion:

    zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
    Enter fullscreen mode Exit fullscreen mode

    The completion can also try to complete partial words you've typed with the following style:

    zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
    Enter fullscreen mode Exit fullscreen mode

    This style would allow you, for example, to complete the file _DSC1704.JPG if you only try to complete its substring 1704.

    The patterns themselves are quite... obscure. If you want a good intellectual challenge, you can look at the manual. I wish you good luck.

    See man zshcompwid for patterns for the style matcher list (search for "COMPLETION MATCHING CONTROL").

    Completion via Keystrokes

    You can bind any completion style to a keystroke instead of using it with the general completion. For that, you need to use the completer _generic.

    For example, if you want to expand aliases each time you hit CTRL+a, you can add the following lines:

    zle -C alias-expension complete-word _generic
    bindkey '^a' alias-expension
    zstyle ':completion:alias-expension:*' completer _expand_alias
    Enter fullscreen mode Exit fullscreen mode

    You can replace alias-expension by the name of your choice. The behavior depends of the completer you use; for expanding aliases, we use _expand_alias. Feel free to use whatever completer you want for your own needs.

    The Module complist

    I wrote already about the module "complist" in this article. We saw there how to move around in the completion menu using the keys "hjkl":

    zmodload zsh/complist
    bindkey -M menuselect 'h' vi-backward-char
    bindkey -M menuselect 'k' vi-up-line-or-history
    bindkey -M menuselect 'j' vi-down-line-or-history
    bindkey -M menuselect 'l' vi-forward-char
    Enter fullscreen mode Exit fullscreen mode

    You can configure many more keystrokes related to the completion menu using these commands:

    • accept-line - Validate the selection and leave the menu.
    • send-break - Leaves the menu selection and restore the previous command.
    • clear-screen - Clear the screen without leaving the menu selection.
    • accept-and-hold - Insert the match in your command and let the completion menu open to insert another match.
    • accept-and-infer-next-history - Insert the match and, in case of directories, open completion menu to complete its children.
    • undo - Undo.
    • vi-forward-blank-word - Move cursor to next group of match.
    • vi-backward-blank-word - Move cursor to previous group of match.
    • beginning-of-buffer-or-history - Move the cursor to the leftmost column.
    • end-of-buffer-or-history - Move the cursor to the rightmost column.
    • vi-insert - Toggle between normal and interactive mode. We've seen the interactive mode above.
    • history-incremental-search-forward and history-incremental-search-backward - Begin incremental search.

    For example, I've configured CTRL+x i to switch to the interactive mode in the completion menu:

    bindkey -M menuselect '^xi' vi-insert
    Enter fullscreen mode Exit fullscreen mode

    See man zshmodules to configure complist (search for "THE ZSH/COMPLIST MODULE").

    Completion Options

    You can also use options to modify the Zsh completion system. To set an option, you need to use the command setopt. For example:

    setopt MENU_COMPLETE
    Enter fullscreen mode Exit fullscreen mode

    Here's a small selection of useful options for configuring the completion system:

    • ALWAYS_TO_END - Always place the cursor to the end of the word completed.
    • LIST_PACKED - The completion menu takes less space.
    • AUTO_MENU - Display the completion menu after two use of the TAB key.
    • AUTO_COMPLETE - Select the first match given by the completion menu. Override AUTO_MENU.
    • AUTO_PARAM_SLASH - When a directory is completed, add a trailing slash instead of a space.
    • COMPLETE_IN_WORD - By default, the cursor goes at the end of the word when completion start. Setting this will not move the cursor and the completion will happen on both end of the word completed.
    • GLOB_COMPLETE - Trigger the completion after a glob * instead of expanding it.
    • LIST_ROWS_FIRST - Matches are sorted in rows instead of columns.

    See man zshoptions for the completion options (search for "Completion").

    Ready to Complete?

    The Zsh completion system is a complex beast, but I tried to do my best to simplify it. I hope it didn't cause any headache on your side.

    What did we learn together in this article?

    • The completion system go through a series of completers first. They'll try to find matches depending on the context (the command you've typed) using different completion functions.
    • The Zsh module "zstyle" allows you to configure settings for a specific Zsh module or widget. Don't let the name style fools you: it can configure way more than visual styles.
    • You can configure the Zsh completion system using options and the module complist, but using zstyle is the most flexible way to tune it following your craziest wishes.

    As you see, the completion system of Zsh is far from being simple. I've covered some of the basics here, but there's much more. Let me know if you want a follow-up article to dive even deeper in this madness.

    Related Resources

    Becoming Mouseless

    Do you want to build a Mouseless Development Environment where the Linux shell has a central role?

    building your mouseless development environment

    Switching between the keyboard and the mouse costs cognitive energy. This book will guide you step by step to set up a Linux-based development environment that keeps your hands on your keyboard.

    Take the brain power you've been using to juggle input devices and focus it where it belongs: on what you create.

  • The Fish Shell Is Amazing
    19 projects | | 25 Nov 2021
    I prefer prezto to oh-my-zsh for performance reasons.

  • Good resources to learn zsh?
    7 projects | | 21 Nov 2021
  • what does a plugin manager/framework do?
    7 projects | | 28 Oct 2021
    7 projects | | 28 Oct 2021
    prezto. Started as a fork of Oh My Zsh but eventually has been completely rewritten. It's more carefully coded than Oh My Zsh but less actively maintained and has higher barrier to entry.
  • Need help with prezto zsh load times (>30s)
    2 projects | | 26 Oct 2021
    You can open an issue on to ask for help. If you want to try diagnosing it yourself, check how long ls -l /mts/yyyy/xxxx/sandbox/scripts takes. If it's slow, this is outside of scope of this sub. If it's fast, run this:
  • New to Mac entirely, and somewhat to DevOps. Any suggestions on getting started moving from primarily Windows/Linux? Given a MacBook Pro 2019 16"
    14 projects | | 7 Sep 2021
    +1, although I prefer zprezto to oh-my-zsh
  • Bash or Zsh
    2 projects | | 15 Jun 2021
    For framework I originally went with the massively popular oh-my-zsh, but after trying Prezto, I was sold on it. It's cleaner, more organized and logical - for my brain anyway. It has all the plug-ins I need.
  • Happens more often than I'd like to admit...
    4 projects | | 19 Apr 2021
  • Creepy text on terminal out of nowhere
    1 project | | 28 Feb 2021
  • [i3-gaps] Glorious Endgame
    2 projects | | 28 Feb 2021
    Zsh (Using prezto with autosuggestions)
  • My Ansible Playbook for setup M1 Mac
    3 projects | | 22 Feb 2021
    roles about prezto Prezto is the configuration framework for Zsh. dotfiles This is my dot files. rustup Install Rust by rustup for my favorite command. command This is my favorite command.


Basic prezto repo stats
13 days ago

sorin-ionescu/prezto is an open source project licensed under MIT License which is an OSI approved license.

Static code analysis for 29 languages.
Your projects are multi-language. So is SonarQube analysis. Find Bugs, Vulnerabilities, Security Hotspots, and Code Smells so you can release quality code every time. Get started analyzing your projects today for free.
Find remote jobs at our new job board There are 30 new remote jobs listed recently.
Are you hiring? Post a new remote job listing for free.