Skip to content

Instantly share code, notes, and snippets.

@Konfekt
Forked from coderofsalvation/snippy.sh
Last active June 4, 2018 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Konfekt/3c8704604e9dae5c07ef1c2fd8e2225b to your computer and use it in GitHub Desktop.
Save Konfekt/3c8704604e9dae5c07ef1c2fd8e2225b to your computer and use it in GitHub Desktop.
modified version of snippy that does NOT use the clipboard and works thus everywhere
#!/usr/bin/env bash
# From
# Based on:
# https://github.com/BarbUk/dotfiles/blob/master/bin/snippy
# https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu
DIR=${HOME}/.snippy
MENU_ENGINE="rofi"
DMENU_ARGS='-dmenu -i -sort -lines 25'
MENU_ARGS=${DMENU_ARGS}
cd "${DIR}" || exit
# Use the filenames in the snippy directory as menu entries.
# Get the menu selection from the user.
FILE=$(find -L . -type f | grep -v '^\.$' | sed 's!\.\/!!' | grep -vE '\.git/|\.gitconfig|\.gitkeep' | ${MENU_ENGINE} ${MENU_ARGS} -p '❯ ')
# just return if nothing was selected
[[ -z "${FILE}" ]] && exit
cat "$FILE" \
| {
IFS= read -r LINE;
xdotool type -- "$LINE";
while IFS= read -r LINE; do
xdotool key Return;
xdotool type -- "$LINE";
done;
} \
| xdotool type --clearmodifiers --file -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment