summaryrefslogtreecommitdiffstats
path: root/public/.local/bin/dmenu-snippet.sh
blob: 46f21ded27a5030df7942c6ffa7ec547d34efd2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
# Simple dmenu-based snippet tool that copies selected snippet to clipboard

SNIPPETS_DIR="$HOME/.local/share/dmenu/snippet"
[ ! -d "$SNIPPETS_DIR" ] && mkdir -p "$SNIPPETS_DIR"

# Select snippet file using dmenu
SNIPPET=$(ls "$SNIPPETS_DIR" | dmenu -i -l 10 -p "Select snippet:")

# Exit if no snippet selected
[ -z "$SNIPPET" ] && exit 1

# Copy snippet content to clipboard
cat "$SNIPPETS_DIR/$SNIPPET" | xclip -selection clipboard

# Notify user
notify-send "Snippet copied" "$SNIPPET copied to clipboard"