From 496264434973fff80ac862e34b0862189c67206e Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Wed, 10 May 2017 10:39:35 +0200 Subject: [PATCH] yasnippets for everything * fixes for org-mode, sql-interactive, eshell * fix for shell script template * new json-mode parameter-key-value for aws cloudformation parameter files. Signed-off-by: Andreas Gerler --- snippets/eshell-mode/aws-filters | 2 +- snippets/json-mode/parameter-key-value | 9 +++++++++ snippets/org-mode/results | 2 +- snippets/org-mode/tablesrcsh | 2 +- snippets/org-mode/tablesrcshy | 2 +- snippets/sql-interactive-mode/grants | 2 +- templates/default-sh.sh | 10 +++++++--- 7 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 snippets/json-mode/parameter-key-value diff --git a/snippets/eshell-mode/aws-filters b/snippets/eshell-mode/aws-filters index 0a775d96..9ba8ff70 100644 --- a/snippets/eshell-mode/aws-filters +++ b/snippets/eshell-mode/aws-filters @@ -2,4 +2,4 @@ # name: aws-filters # key: awsfil # -- ---filters "Name=${1:$$(yas-choose-value '("tag:Name" "tag:Project" "tag:Type" "tag:Cluster" "instance.group-id" "private-ip-address" "description"))},Values=$2" $0 \ No newline at end of file +--filters "Name=${1:$$(yas-choose-value '("tag:Name" "tag:Project" "tag:Type" "tag:Cluster" "instance.group-id" "private-ip-address" "network-interface.subnet-id" "description"))},Values=$2" $0 \ No newline at end of file diff --git a/snippets/json-mode/parameter-key-value b/snippets/json-mode/parameter-key-value new file mode 100644 index 00000000..01858fc3 --- /dev/null +++ b/snippets/json-mode/parameter-key-value @@ -0,0 +1,9 @@ +# -*- mode: snippet -*- +# name: parameter-key-value +# key: pmk_ +# expand-env: ((yas/indent-line 'auto) (yas/wrap-around-region 't)) +# -- +{ + "ParameterKey": "$1", + "ParameterValue": "$2" +},$0 \ No newline at end of file diff --git a/snippets/org-mode/results b/snippets/org-mode/results index 805afd76..1ef39644 100644 --- a/snippets/org-mode/results +++ b/snippets/org-mode/results @@ -3,4 +3,4 @@ # key: :res # add results parameter to src block # -- -:results ${1:$$(yas-choose-value '("verbatim drawer" "table" "list" "silent" "value code :wrap SRC sql"))} $0 \ No newline at end of file +:results ${1:$$(yas-choose-value '("verbatim drawer" "table" "list" "silent" "value code :wrap SRC sql" "value code :wrap SRC json"))} $0 \ No newline at end of file diff --git a/snippets/org-mode/tablesrcsh b/snippets/org-mode/tablesrcsh index f6e37e2e..3f7693ae 100644 --- a/snippets/org-mode/tablesrcsh +++ b/snippets/org-mode/tablesrcsh @@ -7,7 +7,7 @@ | $0 | ${2:#+NAME: ${3:`(replace-regexp-in-string "[: ]" "_" (replace-regexp-in-string "[][]" "" (replace-regexp-in-string ".*/" "" (org-display-outline-path nil t "/" t))))`-src}} -#+BEGIN_SRC shell ${4::session ${5:client}} :var ${6:HOSTS$(upcase (yas-text))}=$1[,0] :cache ${7:$$(yas-choose-value '("yes" "no"))} ${8::res} +#+BEGIN_SRC sh ${4::session ${5:client}} :var ${6:HOSTS$(upcase (yas-text))}=$1[,0] :cache ${7:$$(yas-choose-value '("yes" "no"))} ${8::res} $6=($$6) for INDEX in \$\{!$6[@]\}; do diff --git a/snippets/org-mode/tablesrcshy b/snippets/org-mode/tablesrcshy index b87537eb..ea6a5953 100644 --- a/snippets/org-mode/tablesrcshy +++ b/snippets/org-mode/tablesrcshy @@ -4,7 +4,7 @@ # If you want to reference the output in other src blocks you need a name. # -- ${2:#+NAME: ${3:`(replace-regexp-in-string "[: \"]" "_" (replace-regexp-in-string "[][]" "" (replace-regexp-in-string ".*/" "" (org-display-outline-path nil t "/" t))))`-src}} -#+BEGIN_SRC shell ${4::session ${5:client}} :var ${6:HOSTS$(upcase (yas-text))}=${1:`(yank)`}[,${7:0}] :cache ${8:$$(yas-choose-value '("yes" "no"))} ${9::res} +#+BEGIN_SRC sh ${4::session ${5:client}} :var ${6:HOSTS$(upcase (yas-text))}=${1:`(yank)`}[,${7:0}] :cache ${8:$$(yas-choose-value '("yes" "no"))} ${9::res} $6=($$6) for INDEX in \$\{!$6[@]\}; do diff --git a/snippets/sql-interactive-mode/grants b/snippets/sql-interactive-mode/grants index 49c3ab7b..e770e3f9 100644 --- a/snippets/sql-interactive-mode/grants +++ b/snippets/sql-interactive-mode/grants @@ -2,4 +2,4 @@ # name: grants # key: grants_ # -- -SELECT grantee, object_name FROM v_catalog.grants WHERE object_type = '${1:$$(yas-choose-value '("RESOURCEPOOL" "ROLE" "SCHEMA" "TABLE" "STORAGELOCATION"))}' ORDER BY grantee $0LIMIT 50; \ No newline at end of file +SELECT grantee, object_name, privileges_description FROM v_catalog.grants WHERE object_type = '${1:$$(yas-choose-value '("RESOURCEPOOL" "ROLE" "SCHEMA" "TABLE" "VIEW" "STORAGELOCATION"))}' ORDER BY grantee $0LIMIT 50; \ No newline at end of file diff --git a/templates/default-sh.sh b/templates/default-sh.sh index ada6b5dc..c70f2dfd 100755 --- a/templates/default-sh.sh +++ b/templates/default-sh.sh @@ -13,8 +13,8 @@ `(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))` - --help, -h for help - --man, -m to get this man page. + --help, -h for help + --man, -m to get this man page. --verbose, -v be more verbose. =head1 EXAMPLES @@ -26,7 +26,11 @@ # parse parameters -TEMP=\`getopt -o mhvp --long man,help,verbose,password -n '`(downcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`' -- "$@"\` +TEMP=\`getopt -o mhvp: --long man,help,verbose,password: -n '`(downcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`' -- "$@"\` + +if [ $? != 0 ]; then echo "Wrong parameters..." >&2; exit 1; fi + +eval set -- "$TEMP" while true; do case "\$1" in -- 2.47.3