zsh-smart-insert

April 20, 2025 ยท View on GitHub

zsh-smart-insert Logo

Smart file search and insertion for Zsh โœจ
Insert file paths from fuzzy search directly into your command line.

Contributions Welcome Changelog Available


๐Ÿ” About

zsh-smart-insert is a Zsh plugin that provides interactive widgets to search for files and content using fd, rg, and fzf. It inserts the result directly into your shell with optional command prefixes.

  • ๐Ÿ“‚ File path selection with preview via fd + fzf
  • ๐Ÿง  Content search with reactive reload using ripgrep
  • โŒจ๏ธ Prefix support (e.g. vim, cat, less, code)
  • ๐ŸŽจ Syntax-highlighted preview using bat

โš™๏ธ Requirements

ToolPurposeLink
fzfInteractive fuzzy searchLink
fdFile system searchLink
rgContent search engineLink
batPreview with syntax highlightingLink

๐Ÿš€ Installation

Manual

git clone https://github.com/lgdevlop/zsh-smart-insert.git ~/.zsh-smart-insert
echo "source ~/.zsh-smart-insert/zsh-smart-insert.plugin.zsh" >> ~/.zshrc
source ~/.zshrc

Zinit

zinit light lgdevlop/zsh-smart-insert

Antigen

antigen bundle lgdevlop/zsh-smart-insert

Oh My Zsh (manual plugin)

git clone https://github.com/lgdevlop/zsh-smart-insert.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-smart-insert

Then add to your .zshrc:

plugins=(git zsh-smart-insert)

Reload with:

omz reload   # if using Oh My Zsh
# or
source ~/.zshrc

๐Ÿ’ก Usage

  • Alt+f โ€“ Pick files by name with fd
  • Alt+g โ€“ Search files by name with rg
  • Alt+s โ€“ Search file content with live reload

Each result is inserted at the cursor with an optional prefix.

Example: Select a file with vim as prefix โ†’ inserts vim ./my/file.txt

More examples in project-docs/examples.md


๐Ÿงฉ Configuration

You can customize behavior with environment variables:

# Custom prefix options (fzf menu)
export ZSH_SMART_INSERT_PREFIXES="nvim:less:code"

# Custom directories to ignore in fd/rg
export ZSH_SMART_INSERT_IGNOREDIRS=".git/*:node_modules/:dist/:.venv/"

โŒจ๏ธ Shortcuts

KeyAction
Alt+fFuzzy file picker with preview
Alt+gFile name search with rg
Alt+sContent search with live reload
Ctrl+/Toggle preview in FZF

See project-docs/shortcuts.md for full reference.


๐Ÿ“ Project Structure

.
โ”œโ”€โ”€ zsh-smart-insert.plugin.zsh     # Plugin entry point
โ”œโ”€โ”€ functions/                      # Reusable Zsh helpers
โ”œโ”€โ”€ internal/                       # ZLE widgets (fzf search)
โ”œโ”€โ”€ scripts/                        # Automation (e.g. release notes)
โ”œโ”€โ”€ project-docs/                   # Docs: shortcuts, examples
โ”œโ”€โ”€ .github/workflows/              # CI/CD pipelines
โ”œโ”€โ”€ install.sh                      # Interactive installer

๐Ÿ›ฃ๏ธ Roadmap

  • Prefix selector with command injection
  • Search by name and content
  • Interactive previews with bat
  • Customizable prefixes and ignored paths
  • Per-widget user customization (e.g. ignoredir by mode)
  • Custom themes and per-widget configuration


๐Ÿค Contributing

Contributions are welcome! Open an issue or submit a pull request.

See CONTRIBUTING.md and CODE_OF_CONDUCT.md.


๐Ÿ“„ License

MIT โ€” See LICENSE.


๐Ÿ‘ค Author

Made with โค๏ธ by Leonardo Gomes


โœจ zsh-smart-insert โ€” Insert smarter, search faster!