### Manual Installation of zsh-autosuggestions with Git Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md This demonstrates the manual installation process for zsh-autosuggestions by cloning the repository directly and sourcing the necessary script in your .zshrc file. ```zsh git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh ``` -------------------------------- ### Install zsh-autosuggestions with Homebrew Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md This snippet covers installing zsh-autosuggestions using the Homebrew package manager on macOS. It includes the installation command and the command to source the plugin in your .zshrc. ```zsh brew install zsh-autosuggestions source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh ``` -------------------------------- ### Install zsh-autosuggestions with Oh My Zsh Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md This shows the steps to install zsh-autosuggestions as a plugin for Oh My Zsh. It involves cloning the repository and adding the plugin name to your Oh My Zsh configuration. ```zsh git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions plugins=( # other plugins... zsh-autosuggestions ) ``` -------------------------------- ### Install zsh-autosuggestions with Antigen Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md This snippet shows how to add the zsh-autosuggestions plugin to your Zsh configuration using the Antigen plugin manager. Ensure Antigen is already set up in your .zshrc. ```zsh antigen bundle zsh-users/zsh-autosuggestions ``` -------------------------------- ### Manual Installation of zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Installs the zsh-autosuggestions plugin by cloning the repository and sourcing the plugin in the ~/.zshrc file. Requires Zsh version 4.3.11 or later. ```shell # Clone repository to local directory git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions # Add to ~/.zshrc echo 'source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh' >> ~/.zshrc # Reload shell exec zsh ``` -------------------------------- ### Package Manager Installation of zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Installs zsh-autosuggestions using package managers like pacman on Arch Linux. For Debian/Ubuntu, external repositories or manual installation might be required. ```shell # Arch Linux sudo pacman -S zsh-autosuggestions echo 'source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh' >> ~/.zshrc # Debian/Ubuntu (using OBS repository) # Follow instructions at: https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-autosuggestions&package=zsh-autosuggestions # macOS Homebrew brew install zsh-autosuggestions ``` -------------------------------- ### Oh My Zsh Installation of zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Installs the zsh-autosuggestions plugin for Oh My Zsh users by cloning it into the custom plugins directory and adding it to the plugins array in ~/.zshrc. ```shell # Clone into Oh My Zsh custom plugins directory git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions # Edit ~/.zshrc and add to plugins array plugins=( git docker zsh-autosuggestions ) # Start new terminal session exec zsh ``` -------------------------------- ### Homebrew Installation of zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Installs the zsh-autosuggestions plugin using Homebrew on macOS and adds the source command to the ~/.zshrc file. ```shell # Install via Homebrew brew install zsh-autosuggestions # Add to ~/.zshrc echo 'source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh' >> ~/.zshrc # Reload shell source ~/.zshrc ``` -------------------------------- ### Export Zsh Autosuggestions Strategy Order Source: https://github.com/zsh-users/zsh-autosuggestions/wiki/How-to-Add-Custom-Suggestion-Strategy This command exports the `ZSH_AUTOSUGGEST_STRATEGY` environment variable, defining the order in which suggestion strategies should be applied. Strategies are listed as an array, with 'history' and 'custom' being examples. ```zsh export ZSH_AUTOSUGGEST_STRATEGY=(history custom) ``` -------------------------------- ### Bind Autosuggestion Key Widgets (Zsh) Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Customize key bindings for zsh-autosuggestions widgets. This example demonstrates binding Ctrl+Space to the 'autosuggest-accept' widget, which accepts the current suggestion. ```zsh bindkey '^ ' autosuggest-accept ``` -------------------------------- ### Implement Custom Suggestion Strategy for zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Provides an example of implementing a custom suggestion strategy in `~/.zsh/custom-strategy.zsh` for zsh-autosuggestions. The custom strategy suggests commands from a predefined list and can be combined with the default history strategy in `~/.zshrc`. ```shell # ~/.zsh/custom-strategy.zsh # Create custom suggestion strategy that suggests from a predefined command list _zsh_autosuggest_strategy_custom_commands() { typeset -g suggestion local prefix="$1" # Define common commands local -a common_commands=( 'git status' 'git commit -m ""' 'docker ps -a' 'docker-compose up -d' 'npm run dev' 'npm install' 'kubectl get pods' ) # Find first matching command for cmd in $common_commands; do if [[ "$cmd" = "$prefix"* ]]; then suggestion="$cmd" return 0 fi done } # In ~/.zshrc: source ~/.zsh/custom-strategy.zsh source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh # Use custom strategy first, then fall back to history ZSH_AUTOSUGGEST_STRATEGY=(custom_commands history) ``` -------------------------------- ### Complex zsh-autosuggestions Configuration Example Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt A sample complex configuration for `~/.zshrc` in a production environment for zsh-autosuggestions. This example focuses on visual configuration, specifically setting the `ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE` to 'fg=240,italic' for a dimmed, italicized suggestion appearance. ```shell # ~/.zshrc - Production-ready configuration # Visual configuration ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=240,italic' ``` -------------------------------- ### Remove Plugin Installation Directory (Shell) Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Uninstall zsh-autosuggestions by removing its source directory. This command assumes the plugin was installed in '~/.zsh/zsh-autosuggestions', adjust the path as necessary. ```shell rm -rf ~/.zsh/zsh-autosuggestions ``` -------------------------------- ### Built-in Widget Usage for zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Demonstrates the usage of built-in zsh-autosuggestions widgets. It lists available widgets and provides an example of creating a custom zle widget (`paste-with-no-suggest`) to temporarily disable suggestions during paste operations. ```shell # Available widgets after loading plugin: # - autosuggest-accept Accept current suggestion # - autosuggest-execute Accept and execute suggestion # - autosuggest-clear Clear current suggestion # - autosuggest-fetch Fetch suggestion manually # - autosuggest-disable Disable suggestions # - autosuggest-enable Enable suggestions # - autosuggest-toggle Toggle suggestions on/off # Example: Create function to temporarily disable during paste function paste-with-no-suggest() { zle autosuggest-disable zle bracketed-paste zle autosuggest-enable } zle -N paste-with-no-suggest bindkey '^V' paste-with-no-suggest ``` -------------------------------- ### Build Zsh Autosuggestions Plugin (Make) Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Build the zsh-autosuggestions plugin by running the 'make' command. This process compiles the source files located in the 'src/' directory into the 'zsh-autosuggestions.zsh' file. ```make make ``` -------------------------------- ### Run All zsh-autosuggestions Tests Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Initiates the execution of all tests defined for the zsh-autosuggestions project. This command relies on the project's Makefile to orchestrate the test suite. ```shell make test ``` -------------------------------- ### Troubleshooting Zsh Autosuggestions - Plugin Loading and Suggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Provides solutions for common issues such as suggestions not appearing. It includes checks for plugin loading, enabling suggestions, and terminal color support. ```shell # Solution 1: Check if plugin is loaded typeset -f _zsh_autosuggest_start # If undefined, plugin not loaded - check source command in .zshrc # Solution 2: Check if suggestions are disabled zle autosuggest-enable # Solution 3: Check terminal color support echo -e "\033[38;5;8mTest Gray Text\033[0m" # If gray text not visible, adjust ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE ``` -------------------------------- ### Build Docker Image for Testing zsh-autosuggestions Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Builds a Docker image for testing zsh-autosuggestions with a specific zsh version. This requires a Docker environment and the Dockerfile. ```shell docker build --build-arg TEST_ZSH_VERSION= -t zsh-autosuggestions-test . ``` -------------------------------- ### Integrate zsh-autosuggestions with Syntax Highlighting Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Shows how to integrate zsh-autosuggestions with zsh-syntax-highlighting in `~/.zshrc`. It emphasizes loading zsh-autosuggestions *before* zsh-syntax-highlighting and configuring compatible highlight styles for better visual distinction between suggestions and highlighted code. ```shell # ~/.zshrc - Proper order for plugin loading # Load zsh-autosuggestions BEFORE zsh-syntax-highlighting source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # Configure compatible colors ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=244' typeset -gA ZSH_HIGHLIGHT_STYLES ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=green,underline' ZSH_HIGHLIGHT_STYLES[precommand]='fg=green,underline' ``` -------------------------------- ### Run zsh-autosuggestions Tests with Custom Zsh Binary Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Runs the zsh-autosuggestions tests using a specific zsh binary. This is useful for testing compatibility with different zsh versions or custom builds. ```shell TEST_ZSH_BIN=/bin/zsh make test ``` -------------------------------- ### Optimizing Buffer Size and Performance in zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Tunes the performance of zsh-autosuggestions by setting a maximum buffer size for suggestions and controlling asynchronous fetching behavior in ~/.zshrc. ```shell # ~/.zshrc - Performance tuning # Disable suggestions for buffers longer than 20 characters # Useful when pasting large text blocks ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 # Disable asynchronous mode (synchronous fetching) # By default async is enabled on zsh >= 5.0.8 unset ZSH_AUTOSUGGEST_USE_ASYNC # Enable async mode explicitly (for older zsh versions) ZSH_AUTOSUGGEST_USE_ASYNC=1 ``` -------------------------------- ### Run zsh-autosuggestions Tests in Docker Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Executes the zsh-autosuggestions tests within a previously built Docker container. This mounts the current directory into the container for access to the project files. ```shell docker run -it -v $PWD:/zsh-autosuggestions zsh-autosuggestions-test make test ``` -------------------------------- ### Troubleshooting Zsh Autosuggestions - Integration Order Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Addresses conflicts between zsh-autosuggestions and zsh-syntax-highlighting by specifying the correct loading order in .zshrc to ensure proper functionality. ```shell # In ~/.zshrc: source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ``` -------------------------------- ### Load Zsh Autosuggestions Plugin Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Command to load the zsh-autosuggestions plugin. Ensure the path is correct within your Zsh configuration. ```shell source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh ``` -------------------------------- ### Run Specific zsh-autosuggestions Test Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Executes a single, specific test file for zsh-autosuggestions. This is helpful for debugging or focusing on a particular test case. ```shell TESTS=spec/some_spec.rb make test ``` -------------------------------- ### Configuring Suggestion Strategies for zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Sets the suggestion retrieval methods using the ZSH_AUTOSUGGEST_STRATEGY array in ~/.zshrc. Strategies include history matching, completion, and context-aware matching. ```shell # ~/.zshrc - Configure suggestion strategies # Use only history (default, fastest) ZSH_AUTOSUGGEST_STRATEGY=(history) # Use history first, fall back to completion ZSH_AUTOSUGGEST_STRATEGY=(history completion) # Use context-aware matching based on previous command ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd) # Try multiple strategies in order ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd history completion) # Example usage: With match_prev_cmd strategy # History contains: # cd ~/projects # ls -la # cd ~/documents # ls -la # # After running 'cd ~/documents', typing 'ls' suggests 'ls -la' # because it matches what you did after the previous 'cd' command source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh ``` -------------------------------- ### Zsh Autosuggestions Configuration Variables Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt This section outlines key environment variables for configuring zsh-autosuggestions behavior, including performance, strategy, and security. These variables should be set before sourcing the plugin. ```shell ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 ZSH_AUTOSUGGEST_MANUAL_REBIND=1 ZSH_AUTOSUGGEST_USE_ASYNC=1 ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd history completion) ZSH_AUTOSUGGEST_HISTORY_IGNORE='(rm -rf *|sudo rm *|mkfs.*|dd if=*|> /dev/sd*)' ZSH_AUTOSUGGEST_HISTORY_IGNORE='(*password*|*token*|*api_key*|*secret*)' ZSH_AUTOSUGGEST_COMPLETION_IGNORE='(vim *|nano *|emacs *|ssh *)' ``` -------------------------------- ### Configure Suggestion Strategy in Zsh Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Define the `ZSH_AUTOSUGGEST_STRATEGY` array to control how suggestions are generated. Strategies are tried in order until a suggestion is found. Built-in strategies include 'history', 'completion', and 'match_prev_cmd'. Note that 'match_prev_cmd' may not work as expected with certain history-preserving Zsh options. ```zsh # Example: Try history first, then completion ZSH_AUTOSUGGEST_STRATEGY=(history completion) ``` -------------------------------- ### Troubleshooting Zsh Autosuggestions - Performance and iTerm2 Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Offers solutions for performance issues with large history files by limiting the buffer size and using specific strategies. Also includes a fix for suggestion visibility in iTerm2 related to color settings. ```shell # Solution: Limit buffer size and use history-only strategy ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 ZSH_AUTOSUGGEST_STRATEGY=(history) ZSH_AUTOSUGGEST_USE_ASYNC=1 # Solution: Fix color settings in iTerm2 # Go to iTerm2 → Preferences → Profiles → Colors # Ensure "Basic Colors > Background" differs from "ANSI Colors > Bright Black" ``` -------------------------------- ### Custom Key Bindings for Zsh Autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Defines custom key bindings for interacting with zsh-autosuggestions features like accepting, expanding, executing, and toggling suggestions. ```shell bindkey '^[[Z' autosuggest-accept # Shift+Tab bindkey '^I' expand-or-complete # Tab for normal completion bindkey '^N' autosuggest-execute # Ctrl+N to execute bindkey '^M' autosuggest-toggle # Ctrl+M to toggle ``` -------------------------------- ### Runtime Control and Debugging for zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Provides commands for controlling zsh-autosuggestions at runtime and for debugging purposes. Includes options to enable, disable, toggle suggestions, force fetch, clear suggestions, and check the current strategy or widget mappings. ```shell # Enable/disable suggestions at runtime in your shell: # Disable suggestions zle autosuggest-disable # Enable suggestions zle autosuggest-enable # Toggle suggestions zle autosuggest-toggle # Check if suggestions are disabled if (( ${+_ZSH_AUTOSUGGEST_DISABLED} )); then echo "Suggestions are disabled" else echo "Suggestions are enabled" fi # Force fetch new suggestion for current buffer zle autosuggest-fetch # Clear current suggestion zle autosuggest-clear # Debug: Check current strategy echo $ZSH_AUTOSUGGEST_STRATEGY # Debug: List all bound widgets zle -la | grep autosuggest # Debug: Check widget mappings typeset -p ZSH_AUTOSUGGEST_ACCEPT_WIDGETS ``` -------------------------------- ### Zsh Function for Debugging Autosuggestions Configuration Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt A Zsh function to display detailed configuration information for zsh-autosuggestions, including strategy, highlight style, async mode, buffer size, and widget mappings. ```shell function debug-autosuggestions() { echo "=== Configuration ===" echo "Strategy: $ZSH_AUTOSUGGEST_STRATEGY" echo "Highlight style: $ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE" echo "Async mode: ${+ZSH_AUTOSUGGEST_USE_ASYNC}" echo "Buffer max size: ${ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE:-unlimited}" echo -e "\n=== Widget Mappings ===" zle -la | grep -E "(forward-char|end-of-line)" | while read widget; do echo "$widget -> $(zle -l | grep $widget)" done echo -e "\n=== Suggestion Test ===" echo "Type a command to test suggestions..." } ``` -------------------------------- ### Configure Suggestion Highlight Style in Zsh Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Set the `ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE` variable to customize the appearance of command suggestions. This can include foreground and background colors, as well as text styling like bold or underline. The default is `fg=8`. Ensure color settings are correct, especially for iTerm2 users, to avoid visibility issues. ```zsh # Example: Bold, underlined, pink text on a cyan background ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff00ff,bg=cyan,bold,underline" ``` -------------------------------- ### Manual Widget Rebinding for Zsh Autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Instructions for manually rebinding zsh-autosuggestions widgets when `ZSH_AUTOSUGGEST_MANUAL_REBIND` is set to 1. This is crucial after modifying widget configurations or loading other plugins. ```shell # In ~/.zshrc or interactively: _zsh_autosuggest_bind_widgets # Example workflow: ZSH_AUTOSUGGEST_MANUAL_REBIND=1 source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh # Load other plugins source ~/.zsh/other-plugin.zsh # Rebind after all plugins loaded _zsh_autosuggest_bind_widgets ``` -------------------------------- ### Define Custom Zsh Autosuggestions Strategy Function Source: https://github.com/zsh-users/zsh-autosuggestions/wiki/How-to-Add-Custom-Suggestion-Strategy This function, prefixed with `_zsh_autosuggest_strategy_`, defines a custom suggestion strategy. It must set the global `suggestion` variable with the output of a command or script. The `$1` parameter is passed to the script for context. ```zsh _zsh_autosuggest_strategy_custom() { typeset -g suggestion suggestion=`./my-custom-suggestion-script.sh "$1"` } ``` -------------------------------- ### Custom Key Bindings for zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Customizes key bindings in `~/.zshrc` to control zsh-autosuggestions behavior. It includes bindings for accepting, executing, clearing, and fetching suggestions, as well as toggling them on/off. Supports different key combinations like Ctrl+Space and Alt+Right. ```shell # ~/.zshrc - After loading plugin source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh # Bind Ctrl+Space to accept suggestion bindkey '^ ' autosuggest-accept # Bind Ctrl+E to execute suggestion immediately bindkey '^E' autosuggest-execute # Bind Ctrl+X to clear current suggestion bindkey '^X' autosuggest-clear # Bind Ctrl+F to fetch suggestion manually bindkey '^F' autosuggest-fetch # Bind Ctrl+T to toggle suggestions on/off bindkey '^T' autosuggest-toggle # Bind Alt+Right to accept suggestion (works in many terminals) bindkey '^[[1;3C' autosuggest-accept # Accept partial suggestion with Ctrl+Right Arrow bindkey '^[[1;5C' forward-word # Example workflow with custom bindings: # 1. Type: git sta # 2. See suggestion: git status (in gray) # 3. Press Ctrl+Space to accept full suggestion # 4. Or press Ctrl+Right to accept just "status" word ``` -------------------------------- ### Customizing Widget Behavior in zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Defines Zsh widgets that trigger specific actions like clearing, accepting, or partially accepting suggestions using variables like ZSH_AUTOSUGGEST_CLEAR_WIDGETS in ~/.zshrc. ```shell # ~/.zshrc - Customize which widgets trigger which behaviors # Add widgets to clear suggestions ZSH_AUTOSUGGEST_CLEAR_WIDGETS=( history-search-forward history-search-backward up-line-or-history down-line-or-history my-custom-clear-widget ) # Add widgets to accept suggestions ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=( forward-char end-of-line vi-forward-char vi-end-of-line ) # Add widgets to execute suggestion immediately ZSH_AUTOSUGGEST_EXECUTE_WIDGETS=( # Empty by default - add your own if needed ) # Add widgets for partial acceptance ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=( forward-word emacs-forward-word vi-forward-word ) # Ignore specific widgets ZSH_AUTOSUGGEST_IGNORE_WIDGETS=( orig-* beep zle-* ) source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh ``` -------------------------------- ### Zsh Function to Display Suggestion Statistics Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt A Zsh function that calculates and displays statistics about command history, including total and unique commands, the current suggestion strategy, and whether asynchronous mode is enabled. ```shell function suggestion-stats() { local total=$(wc -l < $HISTFILE) local unique=$(sort -u $HISTFILE | wc -l) echo "Total commands: $total" echo "Unique commands: $unique" echo "Suggestion strategy: $ZSH_AUTOSUGGEST_STRATEGY" echo "Async mode: ${+ZSH_AUTOSUGGEST_USE_ASYNC}" } ``` -------------------------------- ### Customizing Highlight Style for zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Configures the visual appearance of autosuggestions in Zsh using the ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE variable in ~/.zshrc. Supports various color codes and text attributes. ```shell # ~/.zshrc configuration examples # Default style (gray foreground) ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8' # Bright color for better visibility ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=13' # Bold underlined pink text on cyan background ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#ff00ff,bg=cyan,bold,underline' # Subtle italic gray ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=240,italic' # High contrast for light terminals ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=250,bold' # Load plugin after setting style source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh ``` -------------------------------- ### Skip Completion Suggestions by Pattern (Zsh) Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Prevent completion suggestions from being offered when the buffer matches a specified pattern. Set ZSH_AUTOSUGGEST_COMPLETION_IGNORE to a glob pattern to disable completion suggestions for matching cases. This setting only affects the 'completion' suggestion strategy. ```zsh # Disable completion suggestions for git subcommands ZSH_AUTOSUGGEST_COMPLETION_IGNORE="git *" ``` -------------------------------- ### Configure Widget Mapping for Suggestions in Zsh Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Customize how Zsh widgets interact with autosuggestions by modifying arrays like `ZSH_AUTOSUGGEST_CLEAR_WIDGETS`, `ZSH_AUTOSUGGEST_ACCEPT_WIDGETS`, `ZSH_AUTOSUGGEST_EXECUTE_WIDGETS`, `ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS`, and `ZSH_AUTOSUGGEST_IGNORE_WIDGETS`. Widgets not listed in these arrays will fetch a new suggestion after invocation. ```zsh # Example: Define widgets that accept suggestions ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(accept-autosuggestion) ``` -------------------------------- ### Control Asynchronous Suggestions (Zsh) Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Manage asynchronous suggestion fetching in zsh-autosuggestions. By default, suggestions are fetched asynchronously in zsh 5.0.8+. To disable this and use synchronous fetching, unset ZSH_AUTOSUGGEST_USE_ASYNC. For zsh versions older than 5.0.8, setting ZSH_AUTOSUGGEST_USE_ASYNC enables asynchronous mode, though it may cause issues with Ctrl+C. ```zsh # Disable asynchronous suggestions unset ZSH_AUTOSUGGEST_USE_ASYNC # Enable asynchronous suggestions (for zsh < 5.0.8) ZSH_AUTOSUGGEST_USE_ASYNC=1 ``` -------------------------------- ### Disable Autosuggestions for Large Buffers (Zsh) Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Configure the maximum buffer size for which autosuggestions are enabled. Setting ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE to an integer disables suggestions for buffers exceeding this size, which is useful for preventing suggestions on large pasted text. The default is unset, meaning suggestions are attempted for all buffer sizes. ```zsh ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 ``` -------------------------------- ### Filter zsh-autosuggestions using Glob Patterns Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Configures zsh-autosuggestions to filter suggestions based on provided glob patterns in `~/.zshrc`. This allows ignoring specific commands from history or completions, such as 'cd' commands, long commands, or dangerous commands like 'rm -rf'. ```shell # ~/.zshrc - Filter suggestions using glob patterns # Never suggest 'cd' commands from history ZSH_AUTOSUGGEST_HISTORY_IGNORE='cd *' # Ignore commands longer than 50 characters ZSH_AUTOSUGGEST_HISTORY_IGNORE='?(#c50,)' # Ignore multiple patterns (commands starting with space or 'rm') ZSH_AUTOSUGGEST_HISTORY_IGNORE='( *|rm *)' # Ignore dangerous commands ZSH_AUTOSUGGEST_HISTORY_IGNORE='(rm -rf *|sudo rm *|dd *)' # Disable completion suggestions for git commands ZSH_AUTOSUGGEST_COMPLETION_IGNORE='git *' # Disable completion for specific subcommands ZSH_AUTOSUGGEST_COMPLETION_IGNORE='(docker exec *|kubectl exec *)' source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh ``` -------------------------------- ### Ignore History Suggestions by Pattern (Zsh) Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Prevent specific history suggestions from being offered by zsh-autosuggestions. Set ZSH_AUTOSUGGEST_HISTORY_IGNORE to a glob pattern to exclude matching history entries. This setting affects the 'history' and 'match_prev_cmd' suggestion strategies. ```zsh # Ignore 'cd' commands from history ZSH_AUTOSUGGEST_HISTORY_IGNORE="cd *" # Ignore history suggestions 50 characters or longer ZSH_AUTOSUGGEST_HISTORY_IGNORE='?(#c50,)' ``` -------------------------------- ### Disable Automatic Widget Re-binding (Zsh) Source: https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md Prevent zsh-autosuggestions from automatically re-binding widgets on each precmd. Setting ZSH_AUTOSUGGEST_MANUAL_REBIND can improve performance but requires manual re-binding using '_zsh_autosuggest_bind_widgets' if widget lists change or if widgets are wrapped by other plugins. ```zsh ZSH_AUTOSUGGEST_MANUAL_REBIND=1 ``` -------------------------------- ### Disable Automatic Widget Rebinding for zsh-autosuggestions Source: https://context7.com/zsh-users/zsh-autosuggestions/llms.txt Disables automatic widget rebinding for zsh-autosuggestions to potentially improve performance. Users will need to manually call `_zsh_autosuggest_bind_widgets` if widget rebinding is required. ```shell # Disable automatic widget rebinding for better performance # You'll need to manually call _zsh_autosuggest_bind_widgets if needed ZSH_AUTOSUGGEST_MANUAL_REBIND=1 source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.