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-snippetThe flake provides home manager modules with options to enable wayland / x11 support.
Add it to your flake inputs
snippy = {
url = "github:BarbUk/snippy";
inputs.nixpkgs.follows = "nixpkgs";
};Import the home manager module
imports = [
inputs.snippy.homeManagerModule
];
# Or add it to shared modules
sharedModules = [
snippy.homeManagerModule
];Enable it in your home configuration
programs.snippy.enable = true;
# Explicitly disable Wayland / X11 support
# Defaults to installing both dependencies
programs.snippy.enableWayland = false;
programs.snippy.enableX11 = false;Currently only x86_64-linux is supported (aarch64-linux support coming soon).
darwin systems are currently unsupported. See #34
For 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/snippyOn first run, Snippy will automatically create the configuration directory at ~/.config/snippy with a sample snippet.
Prerequisites
Snippy requires the following dependencies to be installed:
Core dependencies:
rofi- Application launcher and menufzf- Command-line fuzzy finderjq- JSON processorgettext- Required forenvsubst(variable expansion)
For X11:
xsel- Command-line clipboard utilityxclip- Clipboard interfacexdotool- X11 automation tool
For Wayland:
wl-clipboard(wl-copyandwl-paste)wtype- Text input automation (for Sway, Hyprland, Niri)dotool- Text input automation (required for KDE Plasma and GNOME)wofi- Application launcher and menu (used on GNOME instead ofrofi)
Optional (for enhanced features):
batorhighlight- Syntax highlighting in previewperl- Required for certain text processing features
# Base deps
sudo apt install rofi fzf jq gettext-base perl gawk
# For wayland (Sway, Hyprland, Niri)
sudo apt install wtype wl-clipboard
# For GNOME on Wayland
sudo apt install wofi
# For KDE / GNOME on Wayland
# dotool can be compiled from source (https://git.sr.ht/~geb/dotool)
# For X11
sudo apt install xsel xclip xdotool# Base deps
sudo dnf install rofi fzf jq gettext perl
# For wayland (Sway, Hyprland, Niri)
sudo dnf install wtype wl-clipboard
# For GNOME on Wayland
sudo dnf install wofi
# For KDE / GNOME on Wayland
# dotool is available via Copr or can be compiled from source
# For X11
sudo dnf install xsel xclip xdotool# Base deps
sudo pacman -Sy rofi fzf jq gettext perl
# For wayland (Sway, Hyprland, Niri)
sudo pacman -Sy wtype wl-clipboard
# For GNOME on Wayland
sudo pacman -Sy wofi
# For KDE / GNOME on Wayland (dotool from AUR)
yay -S dotool
# For X11
sudo pacman -Sy xsel xclip xdotoolSnippy 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 -
##bash- Enable full Bash expansion (variables and command substitution). Use only for trusted snippets.
~/.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
Snippet location
~/.config/snippy
Options
-h, --help Show help
-s, --sort true|false Sort snippet in rofi
-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 <name> Add a new snippet
list list snippet
cat list category
completion bash completion. Use it with: eval "$(snippy completion)"Browse and paste snippets (GUI mode):
snippy
# or explicitly
snippy guiUse it directly inside rofi:
If you already have a keybinding for rofi, you can add snippy as a mod, it will autodetect rofi:
rofi -theme-str 'element-icon { size: 3ch;}' -combi-modi 'snippets:snippy' -show combi -modi combiNote: On Nix, rofi integration is currently unsupported and WIP. To use snippy, use the command snippy instead.
Browse 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>
EOFSnippets can be managed from the provided home manager module. Simply add the snippets to programs.snippy.snippets. For example, the following will create a snippet in $HOME/.config/snippy/snippet/test:
programs.snippy.snippets."snippet/test" = ''
Hello from home manager snippet!
'';When using GUI mode with rofi:
- Enter - Paste processed snippet (variables expanded, commands executed)
- Ctrl+Return - Paste raw snippet content without processing
- Escape - Cancel snippet selection
When using GUI mode with wofi (on GNOME):
- Enter - Paste processed snippet
- Escape - Cancel snippet selection
- X11 - Full support with
xdotool,xsel, andxclip - Wayland - Full support with
wl-clipboard,wtype(wlroots compositors), anddotool(KDE Plasma and GNOME)
Snippy has been tested and works with:
-
Wayland compositors and desktop environments:
- Sway (uses
wtypeandrofi) - Hyprland (uses
wtypeandrofi) - Niri (uses
wtypeandrofi) - KDE Plasma (uses
dotoolandrofi) - GNOME (uses
dotoolandwofi)
- Sway (uses
-
X11 window managers:
- All X11 window managers and desktop environments 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.
