dotfiles/bin/executable_launcher-snippets

15 lines
402 B
Bash

#!/usr/bin/env bash
set -eo pipefail
SNIPPET_DIR=~/.local/share/snippets
if [[ "$1" == "--preview" ]]; then
bat --theme="OneHalfDark" --style=numbers,changes --color always "$SNIPPET_DIR/$2"
exit 0
fi;
SNIPPET=$(find $SNIPPET_DIR -type f -printf "%f\n"| fzf -q "${QUERY}" --preview-window="top:5" --preview="$0 --preview {}")
sleep 0.2
swaymsg exec -- "wtype - < ${SNIPPET_DIR}/${SNIPPET}"