Update snippy to execute bash script in scripts dir

This commit is contained in:
BarbUk 2019-02-01 10:39:51 +04:00
parent f0a5ab1273
commit 02976d1829

9
snippy
View File

@ -9,6 +9,7 @@
# . go up for block snippet for gui paste # . go up for block snippet for gui paste
# . ##noparse header in snippet to not parse # . ##noparse header in snippet to not parse
# . execute command begining by $ # . execute command begining by $
# . execute bash script in $snippets_directory/scripts
# #
# augmented by "opennomad": https://gist.github.com/opennomad/15c4d624dce99066a82d # augmented by "opennomad": https://gist.github.com/opennomad/15c4d624dce99066a82d
# originally written by "mhwombat": https://bbs.archlinux.org/viewtopic.php?id=71938&p=2 # originally written by "mhwombat": https://bbs.archlinux.org/viewtopic.php?id=71938&p=2
@ -37,12 +38,6 @@
# TIP: If you're using XMonad, add something like this to xmonad.hs # TIP: If you're using XMonad, add something like this to xmonad.hs
# ((mod4Mask, xK_s), spawn "/path/to/snippy") # ((mod4Mask, xK_s), spawn "/path/to/snippy")
# #
# 4. Set variables in ~/.snippy.conf. for example
# MENU_ENGINE="dmenu"
# DMENU_ARGS=' -p snippy -fn arial -sf green'
# ZENITY_ARGS='--list --hide-header --column=Snippet --text=snippy'
# GUIPASTE="xdotool key ctrl+v"
# CLIPASTE="xdotool key ctrl+shift+v"
readonly snippets_directory=${HOME}/.snippy readonly snippets_directory=${HOME}/.snippy
readonly MENU_ENGINE="rofi" readonly MENU_ENGINE="rofi"
@ -122,6 +117,8 @@ run() {
# don't parse file with the ##noparse header # don't parse file with the ##noparse header
if grep -qE "^##noparse" "${snippets_directory}/${snippet}"; then if grep -qE "^##noparse" "${snippets_directory}/${snippet}"; then
content="$( tail -n +2 "${snippets_directory}/${snippet}" )" content="$( tail -n +2 "${snippets_directory}/${snippet}" )"
elif [[ $(dirname "${snippet}") == 'scripts' ]] && grep -qE "^#!/bin/bash" "${snippets_directory}/${snippet}"; then
content="$( bash "${snippets_directory}/${snippet}" )"
else else
content="$( bashdown < "${snippets_directory}/${snippet}" )" content="$( bashdown < "${snippets_directory}/${snippet}" )"
fi fi