"~/.emacs.d/elpa/yasnippet-20161110.1226")
(require 'yasnippet)
(setq yas-snippet-dirs '("~/.emacs.d/snippets"))
+
+ (if (equal "work" (getenv "SYSENV"))
+ (add-to-list 'yas-snippet-dirs "~/workorg/snippets"))
+
(yas/reload-all)
(yas-global-mode 1)
(setq yas-indent-line nil)
(add-to-list 'auto-mode-alist '("\\.emacs.d/snippets/[^/]*/" . snippet-mode))
#+END_SRC
+We use lisp in our snippets. So suppress warnings for that:
+
+#+BEGIN_SRC emacs-lisp
+ (add-to-list 'warning-suppress-types '(yasnippet backquote-change))
+#+END_SRC
+
* define some major modes for yasnippets
[2016-05-25 Wed 10:26]
`custom-set-variables' is executed in your .emacs file.
For more information and detailed usage, refer to the project page:
- http://github.com/capitaomorte/yasnippet
+ http://github.com/joaotavora/yasnippet
# -*- mode: snippet -*-
# name: buffer-redirect
-# key: buffer-redirect
+# key: buf_
# To redirect output to an Emacs buffer
# --
-> #<buffer ${1:*test*}>$0
\ No newline at end of file
+> #<buffer *${1:test}*>$0
\ No newline at end of file
- $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 sh ${4::session ${5:client}} :var ${6:HOSTS$(upcase (yas-text))}=$1 :cache ${7:$$(yas-choose-value '("yes" "no"))} :results ${8:$$(yas-choose-value '("verbatim drawer" "table" "list"))}
+#+BEGIN_SRC shell ${4::session ${5:client}} :var ${6:HOSTS$(upcase (yas-text))}=$1 :cache ${7:$$(yas-choose-value '("yes" "no"))} :results ${8:$$(yas-choose-value '("verbatim drawer" "table" "list"))}
for i in \$\{$6\}; do
echo "----------------------------------------"
echo \$\{i\}
--- /dev/null
+# -*- mode: snippet -*-
+# name: sql
+# key: sql_
+# --
+#+begin_src sql $0
+
+#+end_src
\ No newline at end of file
# key: sqlmysql
# --
:PROPERTIES:
-:engine: mysql
-:dbhost: ${1:localhost}
-:dbuser: ${2:user}
-:dbpassword: (concat ${3:bba-db})
-:database: ${4:mysql}
-:cmdline: --protocol=tcp
+:header-args:sql: :engine mysql :dbhost ${1:localhost} :dbuser ${2:user} :dbpassword (concat ${3:bba-db}) :database ${4:mysql} :cmdline --protocol=tcp
:exports: both
:END:
# key: sqlvertica
# --
:PROPERTIES:
-:engine: vertica
-:dbhost: ${1:localhost}
-:dbuser: ${2:user}
-:dbpassword: (if (boundp '${3:bba-db})(concat $3))
-:database: ${4:$2}
+:header-args:sql: :engine: vertica :dbhost: ${1:localhost} :dbuser: ${2:user} :dbpassword: (if (boundp '${3:bba-db})(concat $3)) :database: ${4:$2}
:exports: both
-:dbprologue: "\\a"
:eval: never-export
:END:
# name: srcclient
# key: <sclient
# --
-#+BEGIN_SRC sh :session ${1:client} :results ${2:$$(yas-choose-value '("verbatim drawer" "silent"))}
+#+BEGIN_SRC shell :session ${1:client} :results ${2:$$(yas-choose-value '("verbatim drawer" "silent"))}
$0
#+END_SRC
\ No newline at end of file
# --
Create a session for Emacs:
-#+BEGIN_SRC sh :session ${1:client} :results silent
+#+BEGIN_SRC shell :session ${1:client} :results silent
ssh $0
#+END_SRC
# If you want to reference the output in other src blocks you need a name.
# --
${1:#+NAME: $2}
-#+BEGIN_SRC sh ${3::session ${4:client}} :cache ${5:$$(yas-choose-value '("yes" "no"))} :results ${6:$$(yas-choose-value '("verbatim drawer" "table" "list"))}
+#+BEGIN_SRC shell ${3::session ${4:client}} :cache ${5:$$(yas-choose-value '("yes" "no"))} :results ${6:$$(yas-choose-value '("verbatim drawer" "table" "list"))}
$0
#+END_SRC
\ No newline at end of file
| $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 sh ${4::session ${5:client}} :var ${6:HOSTS$(upcase (yas-text))}=$1[,0] :cache ${7:$$(yas-choose-value '("yes" "no"))} :results ${8:$$(yas-choose-value '("verbatim drawer" "table" "list"))}
+#+BEGIN_SRC shell ${4::session ${5:client}} :var ${6:HOSTS$(upcase (yas-text))}=$1[,0] :cache ${7:$$(yas-choose-value '("yes" "no"))} :results ${8:$$(yas-choose-value '("verbatim drawer" "table" "list"))}
$6=($$6)
for INDEX in \$\{!$6[@]\}; do
# 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 sh ${4::session ${5:client}} :var ${6:HOSTS$(upcase (yas-text))}=${1:`(yank)`}[,${7:0}] :cache ${8:$$(yas-choose-value '("yes" "no"))} :results ${9:$$(yas-choose-value '("verbatim drawer" "table" "list" "value code :wrap SRC sql"))}
+#+BEGIN_SRC shell ${4::session ${5:client}} :var ${6:HOSTS$(upcase (yas-text))}=${1:`(yank)`}[,${7:0}] :cache ${8:$$(yas-choose-value '("yes" "no"))} :results ${9:$$(yas-choose-value '("verbatim drawer" "table" "list" "value code :wrap SRC sql"))}
$6=($$6)
for INDEX in \$\{!$6[@]\}; do
--- /dev/null
+# -*- mode: snippet -*-
+# name: current_epoch
+# key: epo_
+# --
+SELECT current_epoch, ahm_epoch, last_good_epoch FROM v_monitor.system;
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# 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
+++ /dev/null
-# -*- mode: snippet -*-
-# name: grants_resourcepool
-# key: grares_
-# --
-SELECT grantee, object_name FROM grants WHERE object_type = 'RESOURCEPOOL' ORDER BY grantee LIMIT 50;
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: nodes
+# key: nodes_
+# --
+SELECT * FROM nodes;
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: resources
+# key: res_
+# --
+SELECT * FROM ${1:$$(yas-choose-value '("resource_pool_status" "resource_pool_move" "resource_rejections" "resource_rejection_details ORDER BY 1"))};$0
\ No newline at end of file
# name: vertica_users
# key: vertu_
# --
-SELECT user_name,resource_pool,default_roles FROM users ORDER BY 1;
\ No newline at end of file
+SELECT user_name,resource_pool,default_roles FROM v_catalog.users ORDER BY 1;
\ No newline at end of file
--- /dev/null
+sql-interactive-mode