zsh-smart-insert is a custom Zsh plugin that enhances developer productivity by enabling intelligent insertion of files and content directly into the shell. It leverages the fuzzy-finder tool FZF and preview enhancements with bat, as well as smart search capabilities using tools like fd and rg.
- 📁 Search and insert files by name using
fd - 📄 Search and insert file content using
rg - 🖥️ Live previews of files with
bat - ⌨️ FZF-based interactive UI
- ⚙️ Prefix-based smart behavior to determine context (e.g. file path vs content)
These tools must be available in your $PATH. The Dockerfiles included in this repository already install and alias bat and fd accordingly:
ln -s /usr/bin/batcat /usr/local/bin/bat
ln -s $(which fdfind) /usr/local/bin/fdgit clone https://github.com/lgdevlop/zsh-smart-insert.git ${ZSH_CUSTOM:-~/.zsh/custom}/plugins/zsh-smart-insertEnable it by adding it to your .zshrc plugin list:
plugins=(... zsh-smart-insert)The plugin defines widgets bound to specific key combinations (e.g. Ctrl+U) that invoke fzf with a smart context:
- Insert by file name: Filters files and inserts the full path.
- Insert by content match: Searches content and inserts the file path and optionally the line.
Uses bat as the default previewer:
--preview 'bat --style=numbers --color=always {}'--bind 'ctrl-/:change-preview-window(down|hidden|)'- Press
Ctrl+Uto trigger smart insert. - Start typing a file name or content string.
- Use arrows or fuzzy search to locate the file.
- Preview appears in a split window using
bat. - Press Enter to insert the selected result.
The plugin is customizable. You can change the prefix behavior or extend it to support other insertion patterns, such as Markdown snippets or code blocks.
Developed by @lgdevlop, inspired by terminal AI workflows and developer productivity needs.
For full setup instructions and usage examples, see the main README.