]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
org-mode snippets: fixing srcsh
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Thu, 26 May 2016 09:26:23 +0000 (11:26 +0200)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Thu, 26 May 2016 09:26:23 +0000 (11:26 +0200)
- fixing listsrcsh
- fixing tablesrcsh (better loops for tables)
- org heading expansion for both.

snippets/org-mode/listsrcsh
snippets/org-mode/tablesrcsh

index da59eaa56a99e8d379b9486a00056d615777474e..4575ae3864d7baa6daffa33ed53bd77c26698fe6 100644 (file)
@@ -3,12 +3,12 @@
 # key: <srcshlist
 # If you want to reference the output in other src blocks you need a name.
 # --
-#+NAME: ${1:`(replace-regexp-in-string "[: ]" "_" (replace-regexp-in-string "[][]" "" (replace-regexp-in-string ".*/" "" (org-display-outline-path nil nil nil t))))`}
+#+NAME: ${1:`(replace-regexp-in-string "[: ]" "_" (replace-regexp-in-string "[][]" "" (replace-regexp-in-string ".*/" "" (org-display-outline-path nil t "/" t))))`}
 - $0
 
-${2:#+NAME: ${3:`(replace-regexp-in-string "[: ]" "_" (replace-regexp-in-string "[][]" "" (replace-regexp-in-string ".*/" "" (org-display-outline-path nil nil nil t))))`-src}}
-#+BEGIN_SRC sh ${4::session ${5:client}} :var HOSTS=$1 :cache ${6:$$(yas-choose-value '("yes" "no"))} :results ${7:$$(yas-choose-value '("verbatim drawer" "table" "list"))}
-  for i in \$\{HOSTS\}; do
+${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"))}
+  for i in \$\{$6\}; do
     echo "----------------------------------------"
     echo \$\{i\}
     echo "----------------------------------------"
index 5fc068f2bd9eb2589d277b46667a5dc0b471710c..4ccb95053a6a8da05d86b2645d5825eb90c9d115 100644 (file)
@@ -3,15 +3,16 @@
 # key: <srcshtable
 # If you want to reference the output in other src blocks you need a name.
 # --
-#+NAME: ${1:`(replace-regexp-in-string "[: ]" "_" (replace-regexp-in-string "[][]" "" (replace-regexp-in-string ".*/" "" (org-display-outline-path nil nil nil t))))`}
+#+NAME: ${1:`(replace-regexp-in-string "[: ]" "_" (replace-regexp-in-string "[][]" "" (replace-regexp-in-string ".*/" "" (org-display-outline-path nil t "/" t))))`}
 | $0 |
 
-${2:#+NAME: ${3:`(replace-regexp-in-string "[: ]" "_" (replace-regexp-in-string "[][]" "" (replace-regexp-in-string ".*/" "" (org-display-outline-path nil nil nil t))))`-src}}
-#+BEGIN_SRC sh ${4::session ${5:client}} :var HOSTS=$1[,0] :cache ${6:$$(yas-choose-value '("yes" "no"))} :results ${7:$$(yas-choose-value '("verbatim drawer" "table" "list"))}
-  for i in \$\{HOSTS\}; do
+${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"))}
+$6=($$6)
+
+for INDEX in \`seq 0 1 \$\{#$6[@]\}\`; do
     echo "----------------------------------------"
-    echo \$\{i\}
+    echo \$\{$6[$\{INDEX\}]\}
     echo "----------------------------------------"
-    ssh -x \$\{i\}
   done
 #+END_SRC