dotfiles/scripts/menu/menu-snippets
2023-10-18 13:45:42 -06:00

14 lines
374 B
Bash
Executable file

#!/bin/sh
# Copy snippets to clipboard
# Snippets directory
snippets=~/Documents/snippets
# Select using menu, copy if successful
snippet=$(ls "$snippets" | menu "Snippet:")
# Exit if empty
[ -z "$snippet" ] && exit
# Copy to clipboard and notify otherwise
printf '%s' "$(cat $snippets/$snippet)" |
xsel -ib && notify-send "Snippet" "'$snippet' copied to clipboard!"