Examples: Using zsh-smart-insert
April 20, 2025 ยท View on GitHub
This document demonstrates how to use the zsh-smart-insert plugin in practical scenarios for boosting file interaction productivity in the terminal.
๐ Scenario 1: Open a File with a Command Prefix
Scenario 1 - Steps
- Press
Alt+fto launch the file picker usingfd. - Browse and select a file (e.g.,
main.go). - Choose a prefix command when prompted (e.g.,
vim).
Scenario 1 - Result
vim ./internal/main.go
The full command is inserted into your terminal buffer, ready for execution.
๐ Scenario 2: Search for a File by Name
Scenario 2 - Steps
- Press
Alt+gto search filenames usingripgrep. - Type a partial name (e.g.,
readme). - Select the desired file.
- Choose a command like
batorless.
Scenario 2 - Result
bat ./README.md
๐ง Scenario 3: Search for a File by Content
Scenario 3 - Steps
- Press
Alt+sto search inside file contents. - Type a keyword (e.g.,
choose_prefix). - Select a matching file from the preview.
- Choose a prefix like
codeorvim.
Scenario 3 - Result
code ./functions/choose_prefix.zsh
โ Scenario 4: Insert File Path Without a Prefix
Scenario 4 - Steps
- Launch any widget (
Alt+f,Alt+g, orAlt+s). - Select the desired file.
- When prompted, choose the empty prefix option.
Scenario 4 - Result
./project-docs/shortcuts.md
This is useful when scripting or composing custom shell commands.
Tips
- Use
Ctrl+/to toggle the file preview inside FZF. - Use
ESCorCtrl+Cto cancel the widget interface without inserting anything. - Prefix options include:
cat,vim,less,bat,code, or no prefix.
Last updated: 2025-04-19