Convert Figma logo to code with AI

Aloxaf logofzf-tab

Replace zsh's default completion selection menu with fzf!

3,172
94
3,172
80

Top Related Projects

63,665

:cherry_blossom: A command-line fuzzy finder

Fish-like autosuggestions for zsh

Additional completion definitions for Zsh.

🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.

Feature-rich syntax highlighting for ZSH

A Zsh theme

Quick Overview

Aloxaf/fzf-tab is a Zsh plugin that enhances tab completion using fzf (fuzzy finder). It replaces Zsh's default completion selection menu with fzf, providing a more interactive and efficient way to navigate and select completion options.

Pros

  • Improves completion experience with fuzzy search capabilities
  • Customizable appearance and behavior through various configuration options
  • Supports continuous completion, allowing for multiple selections
  • Integrates well with existing Zsh completion systems

Cons

  • Requires fzf to be installed separately
  • May have a slight learning curve for users accustomed to traditional Zsh completion
  • Can potentially slow down completion for very large lists of options
  • Might conflict with other Zsh completion plugins or customizations

Code Examples

  1. Basic usage (in .zshrc):
source /path/to/fzf-tab.plugin.zsh
  1. Customizing fzf-tab appearance:
zstyle ':fzf-tab:*' fzf-flags --height 40% --layout=reverse
  1. Configuring continuous completion:
zstyle ':fzf-tab:*' continuous-trigger '/'

Getting Started

  1. Install fzf if not already installed:

    git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
    ~/.fzf/install
    
  2. Clone the fzf-tab repository:

    git clone https://github.com/Aloxaf/fzf-tab ~/.zsh/fzf-tab
    
  3. Add the following to your .zshrc:

    source ~/.zsh/fzf-tab/fzf-tab.plugin.zsh
    
  4. Restart your Zsh session or source your .zshrc:

    source ~/.zshrc
    

Competitor Comparisons

63,665

:cherry_blossom: A command-line fuzzy finder

Pros of fzf

  • More versatile and can be used in various contexts beyond shell completion
  • Offers a wider range of customization options and features
  • Has a larger community and more extensive documentation

Cons of fzf

  • Requires more setup and configuration for shell completion
  • May have a steeper learning curve for new users
  • Not specifically optimized for Zsh tab completion

Code Comparison

fzf-tab:

zstyle ':fzf-tab:*' fzf-command fzf
zstyle ':fzf-tab:*' fzf-flags --height 40%
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'

fzf (for Zsh completion):

source /path/to/fzf/shell/completion.zsh
export FZF_COMPLETION_TRIGGER='**'
_fzf_compgen_path() {
  fd --hidden --follow --exclude ".git" . "$1"
}

Summary

fzf-tab is a Zsh-specific plugin that provides fuzzy completion using fzf, while fzf is a more general-purpose fuzzy finder. fzf-tab offers easier setup for Zsh tab completion, but fzf provides greater flexibility for use in various scenarios. Both tools enhance the command-line experience, with fzf-tab being more focused on Zsh completion and fzf offering broader applications.

Fish-like autosuggestions for zsh

Pros of zsh-autosuggestions

  • Simpler setup and configuration
  • Provides inline suggestions based on command history
  • Lightweight and less resource-intensive

Cons of zsh-autosuggestions

  • Limited to historical suggestions only
  • Lacks advanced filtering and selection capabilities
  • No visual menu for multiple suggestions

Code Comparison

zsh-autosuggestions:

# Enable autosuggestions
source /path/to/zsh-autosuggestions.zsh

# Configure suggestion color
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'

fzf-tab:

# Enable fzf-tab
source /path/to/fzf-tab.plugin.zsh

# Configure fzf-tab options
zstyle ':fzf-tab:*' fzf-flags --height 40%
zstyle ':completion:*:descriptions' format '[%d]'

Summary

zsh-autosuggestions offers a straightforward, history-based suggestion system that's easy to set up and use. It's ideal for users who prefer a lightweight solution focused on command history. However, it lacks the advanced filtering and visual selection features provided by fzf-tab.

fzf-tab, on the other hand, provides a more powerful and flexible tab completion system with fuzzy finding capabilities. It offers a visual menu for multiple suggestions and allows for more customization. However, it may require more setup and system resources compared to zsh-autosuggestions.

The choice between these two plugins depends on the user's preference for simplicity versus advanced functionality in their Zsh environment.

Additional completion definitions for Zsh.

Pros of zsh-completions

  • Extensive collection of completion definitions for various commands and tools
  • Community-driven with contributions from many users
  • Regular updates and maintenance

Cons of zsh-completions

  • Requires manual installation and configuration
  • May conflict with existing completions or require additional setup
  • Limited to static completion definitions

Code comparison

zsh-completions:

# Example completion function
_example_command() {
  _arguments \
    '1:first arg:->first' \
    '2:second arg:->second'
}

fzf-tab:

# Enable fzf-tab
source /path/to/fzf-tab.plugin.zsh

# Customize fzf-tab options
zstyle ':fzf-tab:*' fzf-command fzf
zstyle ':fzf-tab:*' fzf-flags --height 40%

fzf-tab provides a more interactive and dynamic completion experience using fzf, while zsh-completions offers a wide range of pre-defined completion functions. fzf-tab enhances the existing completion system, whereas zsh-completions extends it with additional definitions. The choice between them depends on whether you prefer a more interactive approach or a broader set of completion definitions for specific commands.

🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.

Pros of zsh-autocomplete

  • Offers a more comprehensive autocomplete experience, including real-time suggestions as you type
  • Provides inline suggestions and menu completion for a wider range of Zsh features
  • Integrates with various Zsh plugins and frameworks out of the box

Cons of zsh-autocomplete

  • May have a steeper learning curve due to its extensive features
  • Can potentially slow down the shell on older systems or with large directories
  • Might conflict with some existing Zsh configurations or plugins

Code Comparison

zsh-autocomplete:

zstyle ':autocomplete:*' min-input 1
zstyle ':autocomplete:*' insert-unambiguous yes
zstyle ':autocomplete:*' widget-style menu-select

fzf-tab:

zstyle ':fzf-tab:*' fzf-command fzf
zstyle ':fzf-tab:*' fzf-preview 'bat --color=always --style=numbers --line-range=:500 {}'
zstyle ':fzf-tab:*' switch-group ',' '.'

Both plugins enhance Zsh's tab completion, but they take different approaches. zsh-autocomplete provides a more holistic autocomplete solution, while fzf-tab focuses on integrating fzf into Zsh's tab completion system. The choice between them depends on personal preference and specific use cases.

Feature-rich syntax highlighting for ZSH

Pros of fast-syntax-highlighting

  • Provides real-time syntax highlighting for Zsh commands and scripts
  • Supports a wide range of programming languages and file types
  • Offers customizable themes and color schemes

Cons of fast-syntax-highlighting

  • May have a slight performance impact on very large scripts or commands
  • Requires manual installation and configuration
  • Limited to syntax highlighting functionality

Code Comparison

fast-syntax-highlighting:

# Enable fast-syntax-highlighting
source /path/to/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh

# Customize theme
fast-theme spa

fzf-tab:

# Enable fzf-tab
source /path/to/fzf-tab/fzf-tab.plugin.zsh

# Customize fzf-tab options
zstyle ':fzf-tab:*' fzf-command fzf
zstyle ':fzf-tab:*' fzf-flags '--height=50%'

Summary

fast-syntax-highlighting focuses on enhancing the visual appearance of Zsh commands and scripts through real-time syntax highlighting. It supports multiple languages and offers customizable themes. However, it may have a slight performance impact on large scripts and requires manual setup.

fzf-tab, on the other hand, enhances Zsh's tab completion functionality by integrating fzf (fuzzy finder) into the completion process. It provides an interactive and fuzzy-searchable completion menu, which can significantly improve command-line productivity. fzf-tab is more focused on enhancing user interaction rather than visual aesthetics.

Both plugins serve different purposes and can be used together to create a more powerful and visually appealing Zsh environment.

A Zsh theme

Pros of powerlevel10k

  • Highly customizable and feature-rich Zsh theme with extensive configuration options
  • Fast and efficient, with instant prompt feature for quick shell startup
  • Supports a wide range of programming languages and version control systems

Cons of powerlevel10k

  • Primarily focused on shell appearance and prompt customization, not tab completion
  • May require more setup and configuration time compared to simpler plugins

Code comparison

powerlevel10k (theme configuration):

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
  os_icon
  dir
  vcs
)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
  status
  command_execution_time
)

fzf-tab (tab completion configuration):

zstyle ':fzf-tab:*' fzf-command fzf
zstyle ':fzf-tab:*' fzf-flags --height 40%
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'

Summary

powerlevel10k is a powerful Zsh theme that focuses on customizing the shell prompt and appearance, offering extensive configuration options and performance optimizations. fzf-tab, on the other hand, enhances tab completion functionality using fzf fuzzy finder. While powerlevel10k provides a visually appealing and informative prompt, fzf-tab improves the interactive experience of command-line completion. The choice between the two depends on whether you prioritize prompt customization or enhanced tab completion in your Zsh setup.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

fzf-tab

CI GitHub license

Replace zsh's default completion selection menu with fzf!

asciicast

Table of Contents

Install

[!IMPORTANT]

  1. make sure fzf is installed
  2. fzf-tab needs to be loaded after compinit, but before plugins which will wrap widgets, such as zsh-autosuggestions or fast-syntax-highlighting
  3. Completions should be configured before compinit, as stated in the zsh-completions manual installation guide.

Manual

First, clone this repository.

git clone https://github.com/Aloxaf/fzf-tab ~/somewhere

Then add the following line to your ~/.zshrc.

autoload -U compinit; compinit
source ~/somewhere/fzf-tab.plugin.zsh

Antigen

antigen bundle Aloxaf/fzf-tab

Zinit

zinit light Aloxaf/fzf-tab

Oh-My-Zsh

Clone this repository to your custom directory and then add fzf-tab to your plugin list.

git clone https://github.com/Aloxaf/fzf-tab ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fzf-tab

Prezto

Clone this repository to your contrib directory and then add fzf-tab to your module list in .zpreztorc.

git clone https://github.com/Aloxaf/fzf-tab $ZPREZTODIR/contrib/fzf-tab

Usage

Just press Tab as usual~

Available keybindings:

  • Ctrl+Space: select multiple results, can be configured by fzf-bindings tag

  • F1/F2: switch between groups, can be configured by switch-group tag

  • /: trigger continuous completion (useful when completing a deep path), can be configured by continuous-trigger tag

Available commands:

  • disable-fzf-tab: disable fzf-tab and fallback to compsys

  • enable-fzf-tab: enable fzf-tab

  • toggle-fzf-tab: toggle the state of fzf-tab. This is also a zle widget.

Configure

A common configuration is:

# disable sort when completing `git checkout`
zstyle ':completion:*:git-checkout:*' sort false
# set descriptions format to enable group support
# NOTE: don't use escape sequences here, fzf-tab will ignore them
zstyle ':completion:*:descriptions' format '[%d]'
# set list-colors to enable filename colorizing
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# force zsh not to show completion menu, which allows fzf-tab to capture the unambiguous prefix
zstyle ':completion:*' menu no
# preview directory's content with eza when completing cd
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
# switch group using `<` and `>`
zstyle ':fzf-tab:*' switch-group '<' '>'

Tmux

If you're using tmux >= 3.2, we provide a script ftb-tmux-popup to make full use of it's "popup" feature.

zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup

BTW, you can also use this script outside the fzf-tab.

ls | ftb-tmux-popup

asciicast

For more information, please see Wiki#Configuration.

Binary module

By default, fzf-tab uses zsh-ls-colors to parse and apply ZLS_COLORS if you have set the list-colors tag.

However, it is a pure zsh script and is slow if you have too many files to colorize. fzf-tab is shipped with a binary module to speed up this process. You can build it with build-fzf-tab-module, then it will be enabled automatically.

Difference from other plugins

fzf-tab doesn't do "complete", it just shows you the results of the default completion system.

So it works EVERYWHERE (variables, function names, directory stack, in-word completion, etc.). And most of your configuration for default completion system is still valid.

Compatibility with other plugins

Some plugins may also bind "^I" to their custom widget, like fzf/shell/completion.zsh or ohmyzsh/lib/completion.zsh.

By default, fzf-tab will call the widget previously bound to "^I" to get the completion list. So there is no problem in most cases, unless fzf-tab is initialized before a plugin which doesn't handle the previous binding properly.

So if you find your fzf-tab doesn't work properly, please make sure it is the last plugin to bind "^I" (If you don't know what I mean, just put it to the end of your plugin list).

Related projects