A powerful Linux snippet manager for enhanced productivity and workflow automation.
Snippy is a versatile command-line snippet manager that seamlessly integrates with your desktop environment to provide quick access to frequently used text snippets, commands, and templates.
Table of Contents
Snippy is available in the AUR as snippy-snippet.
Install using your preferred AUR helper:
yay -S snippy-snippetFor local user installation:
curl -fsSL https://github.com/barbuk/snippy/releases/latest/download/snippy \
--create-dirs --output ~/.bin/snippy
chmod +x ~/.bin/snippyEnsure ~/.bin is in your PATH.
For system-wide installation:
sudo curl -fsSL https://github.com/barbuk/snippy/releases/latest/download/snippy \
--output /usr/bin/snippy
sudo chmod +x /usr/bin/snippyPrerequisites
Snippy requires the following dependencies to be installed:
Core dependencies:
rofi- Application launcher and menufzf- Command-line fuzzy finderjq- JSON processor
For X11:
xsel- Command-line clipboard utilityxclip- Clipboard interfacexdotool- X11 automation tool
For Wayland:
wtype- Text input automationwl-clipboard(wl-copyandwl-paste)
Optional (for enhanced features):
batorhighlight- Syntax highlighting in previewperl- Required for certain text processing features
On first run, Snippy will automatically create the configuration directory at ~/.config/snippy with a sample snippet.
Snippy provides advanced clipboard handling that preserves your workflow:
- Automatic clipboard restoration - Your original clipboard content is automatically restored after pasting a snippet
- Dynamic clipboard integration - Use
{clipboard}placeholder to embed current clipboard content into snippets
~/.config/snippy/create\ database
CREATE DATABASE `{clipboard}` CHARACTER SET utf8 COLLATE utf8_general_ci;- URL-encoded clipboard - Use
{clipboard_urlencode}for web-safe clipboard content
~/.config/snippy/cached\ url
https://cachedview.nl/#{clipboard_urlencode}
Control exactly where the cursor lands after snippet insertion using the {cursor} placeholder:
Single-line positioning:
~/.config/snippy/pre
<pre>{cursor}</pre>Multi-line positioning:
~/.config/snippy/pre\ multiline
<pre>
{cursor}
</pre>Snippy intelligently handles cursor movement in both CLI and GUI contexts, including special support for Vim.
Variable expansion: Snippy processes snippets through a bash-like template engine, allowing you to use variables and command substitution:
~/.config/snippy/date\ and\ user
Current date: $(date +%Y-%m-%d)
Username: $USERCommand execution:
Snippets starting with $ are executed as commands, and their output is pasted:
~/.config/snippy/date
$(date +%Y-%m-%d-%Hh%Mm%S)Script execution:
Bash scripts stored in $snippets_directory/scripts are automatically executed when selected.
Raw content mode:
Use Ctrl+Return to paste the snippet source code instead of its processed output.
Control snippet behavior with special headers:
##noparse- Disable variable expansion and command execution
~/.config/snippy/cmd\ last\ month
##noparse
date --date="$(date +%F) -1 month" +%F##tmpfile- Create a tempfile accessible via$tmpfilevariable
~/.config/snippy/test\ tmpfile
##tmpfile
$(xsel -b > $tmpfile; cat $tmpfile)##richsnippet- Enable HTML clipboard support for rich text pasting
~/.config/snippy/test\ html
##richsnippet
<strong>should be pasted as strong</strong>Organize your snippets with directory-based categorization. The top-level directory name is used as an icon identifier in rofi:
terminal/
├── commands/
│ └── date
└── scripts/
└── backup
/usr/bin/snippy-snippet 1.0.11
Usage:
/usr/bin/snippy-snippet [OPTION] ACTION
Snippy snippets manager
Options
-h, --help: Show help
-s, --sort: true or false Sort snippet in rofi (default)
-m, --sorting-method: fzf (default) or levenshtein
Actions
gui Browse snippet and paste it in the focused window (default)
cli list snippet in cli mode, only copy snippet in the paste buffer
edit Browse snippet and edit it
add snippet_name Add a new snippet
list list snippet
cat list category
completion bash completionBrowse and paste snippets (GUI mode):
snippy
# or explicitly
snippy guiBrowse snippets in terminal:
snippy cliCreate a new snippet:
snippy add database/mysql-createEdit an existing snippet:
snippy editList all snippets:
snippy listEnable tab completion for Snippy commands and options by adding this line to your ~/.bashrc:
eval "$(snippy completion)"Snippets are stored as plain text files in ~/.config/snippy. The directory structure you create becomes your snippet organization system.
Create a file with your desired content:
mkdir -p ~/.config/snippy/greetings
echo "Hello from Snippy!" > ~/.config/snippy/greetings/helloUse bash variable expansion and command substitution:
mkdir -p ~/.config/snippy/dates
cat > ~/.config/snippy/dates/current-datetime << 'EOF'
Current date and time: $(date '+%Y-%m-%d %H:%M:%S')
User: $USER
EOFUse Snippy's special placeholders:
mkdir -p ~/.config/snippy/sql
cat > ~/.config/snippy/sql/create-database << 'EOF'
CREATE DATABASE `{clipboard}`
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
USE `{clipboard}`;
{cursor}
EOFCreate a snippet that executes a command:
echo '$(date +%Y-%m-%d-%Hh%Mm%S)' > ~/.config/snippy/dates/timestampCreate an executable bash script in the scripts directory:
mkdir -p ~/.config/snippy/scripts
cat > ~/.config/snippy/scripts/system-info << 'EOF'
#!/bin/bash
echo "System Information"
echo "=================="
echo "Hostname: $(hostname)"
echo "Kernel: $(uname -r)"
echo "Uptime: $(uptime -p)"
EOFPrevent processing of special characters:
cat > ~/.config/snippy/examples/raw << 'EOF'
##noparse
This will be pasted as-is: $(date) $USER {cursor} {clipboard}
EOFEnable HTML clipboard support:
cat > ~/.config/snippy/html/bold-text << 'EOF'
##richsnippet
<strong>{clipboard}</strong>
EOFWhen using the GUI mode with rofi:
- Enter - Paste processed snippet (variables expanded, commands executed)
- Ctrl+Return - Paste raw snippet content without processing
- Escape - Cancel snippet selection
- X11 - Full support with xdotool, xsel, and xclip
- Wayland - Full support with wl-clipboard and wtype
Snippy has been tested and works with:
-
Wayland compositors:
- Sway
- Hyprland
- Niri
-
X11 window managers:
- All X11 window managers should be supported
Snippy uses a convention-over-configuration approach. Most behavior is controlled through snippet headers and directory structure rather than configuration files.
XDG_CONFIG_HOME- If set, snippets are stored in$XDG_CONFIG_HOME/snippyEDITOR- Used for editing snippets (defaults tovim)
Default: ~/.config/snippy
You can organize snippets in subdirectories. The top-level directory name is used as the icon identifier in rofi.
Contributions are welcome! Here are ways you can help:
- Report bugs and request features via GitHub Issues
- Submit pull requests for bug fixes and enhancements
- Improve documentation
- Share your snippet collections and use cases
Snippy is licensed under the GNU General Public License v3.0.
Snippy builds upon the work of several contributors:
- barbuk - Current maintainer (GitHub)
- opennomad - Major enhancements (Gist)
- mhwombat - Original concept (Arch Linux Forums)
- sessy - Initial implementation (Arch Linux Forums)
Special thanks to the open-source community for the excellent tools that make Snippy possible: rofi, fzf, and all the clipboard and automation utilities.