From 7e7b0a8c65e5d3dff42f4b8208cef61cba24ac12 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Fri, 24 Mar 2017 01:10:48 +0400 Subject: [PATCH] noparse header to disable bashdown on snippet --- snippy | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/snippy b/snippy index 9a3a943..ae7e4f1 100755 --- a/snippy +++ b/snippy @@ -4,7 +4,8 @@ # augmented by barbuk: https://github.com/BarbUk/dotfiles/blob/master/bin/snippy # . restore current clipboard # . {clipboard} placeholder to use current clipboard in snippet -# . {cursor} placeholder to place the cursor +# . {cursor} placeholder to place the cursor +# . ##noparse header in snippet to not parse # augmented by "opennomad": https://gist.github.com/opennomad/15c4d624dce99066a82d # originally written by "mhwombat": https://bbs.archlinux.org/viewtopic.php?id=71938&p=2 # Based on "snippy" by "sessy" @@ -74,9 +75,9 @@ run(){ if [ -f "${DIR}/${FILE}" ]; then # Put the contents of the selected file into the paste buffer. - # bang is a bash template, don't pass it to bashdown - if [[ ${FILE} == "bang" ]]; then - content="$(cat "${DIR}/${FILE}")" + # don't parse file with the ##noparse header + if grep -qE "^##noparse" "${FILE}"; then + content="$(tail -n +2 "${DIR}/${FILE}")" else content="$(bashdown < "${DIR}/${FILE}")" fi