commit b5f808b28d5d11d7eb1fb24458554e264301a472 parent 1d41ee7760849f14fae2f23159908f284dab9a69 Author: Alex Balgavy <alex@balgavy.eu> Date: Wed, 28 Jul 2021 12:32:50 +0200 vim: ultisnips sh printfq snippet Diffstat:
M | vim/ultisnips/sh.snippets | | | 5 | +++++ |
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/vim/ultisnips/sh.snippets b/vim/ultisnips/sh.snippets @@ -150,3 +150,8 @@ elif [ $# -gt 0 ]; then ${2:#handle arguments} fi endsnippet + +snippet printfq "A POSIX way to do printf %q" bw +printfq() { printf "'%s'\\n" "$(printf '%s' "$1" | sed -e "s/'/'\\\\''/g")"; } +$0 +endsnippet