5 Angajamente a25ade4b5f ... f44fc32ec3

Autor SHA1 Permisiunea de a trimite mesaje. Dacă este dezactivată, utilizatorul nu va putea trimite nici un fel de mesaj Data
  Daniel Sheffield f44fc32ec3 instead of relying on passwordless sudo, supply password via stdin and get csr from socat 1 lună în urmă
  Daniel Sheffield 2c3a64f263 check required deps are installed 1 lună în urmă
  Daniel Sheffield 68d431a1fc add clipboard support in visual mode 2 luni în urmă
  Daniel Sheffield 7b879692da add mandoc preview for markdown 2 luni în urmă
  Daniel Sheffield 6bd54b0b1c add bible abbreviations for markdown files only 2 luni în urmă
3 a modificat fișierele cu 121 adăugiri și 78 ștergeri
  1. 30 4
      termux-shortcuts/.shortcuts/create-client-cert.sh
  2. 7 0
      vim/.termux/mdview.sh
  3. 84 74
      vim/vimfiles/vimrc

+ 30 - 4
termux-shortcuts/.shortcuts/create-client-cert.sh

@@ -1,8 +1,21 @@
 #!/bin/bash
 set -euo pipefail
 set -x
+
+DEPS=(
+    openssl
+    ssh
+    socat
+)
+for pkg in "$DEPS[@]"
+do
+    which openssl
+done
+
 signing_server="${1}"
 signing_cert="${2:-/etc/private-ca/server-cert.pem}"
+local_port=16839
+remote_port=55555
 
 subject_file="${BASH_SOURCE[0]%.*}.subject"
 [ -f "${subject_file}" ] || cat <<EOF > "${subject_file}"
@@ -38,8 +51,11 @@ openssl genrsa -out "${user}.key" 4096
 # download server cert
 [ -f server-cert.pem ] || scp "$signing_server:$signing_cert" .
 
-# create extensions file
-ssh $signing_server "cat - > ~/${user}.ext" <<EOF
+signing_script=$(cat <<EOF
+openssl x509 -req \
+    -CA "$signing_cert" -CAkey "${signing_cert%cert.pem}key.pem" \
+    -CAcreateserial -days 90 -sha256 \
+    -extfile <(cat <<'FILE'
 authorityKeyIdentifier=keyid,issuer
 basicConstraints=CA:FALSE
 keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
@@ -47,14 +63,24 @@ subjectAltName = @alt_names
 
 [alt_names]
 DNS.1 = ${user}
+FILE
+) \
+    -in <(socat TCP-LISTEN:$remote_port,accept-timeout=10,reuseaddr STDOUT)
 EOF
+)
 
+read -rsp 'sudo password:' PW
 # sign csr
-ssh "$signing_server" "sudo openssl x509 -req -CA "$signing_cert" -CAkey "${signing_cert%cert.pem}key.pem" -CAcreateserial -days 90 -sha256 -extfile ~/${user}.ext" < <(openssl req \
+ssh -L "$local_port:127.0.0.1:$remote_port" "$signing_server" sudo -S bash -c "'$signing_script'" <<<"$PW" > "${user}.crt" &
+sleep 1
+socat -u STDIN "TCP:127.0.0.1:$local_port" < <(openssl req \
 	-new \
 	-key "${user}.key" \
 	-out - \
-	-subj "$subject" </dev/null) > "${user}.crt"
+	-subj "$subject" </dev/null)
+wait
+
+cat ${user}.crt
 
 # create pfx
 openssl pkcs12 -export -inkey "${user}.key" -in "${user}.crt" -certfile server-cert.pem -name "${user} $(date +%Y-%m-%d)" -out - > "$output"

+ 7 - 0
vim/.termux/mdview.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+#pandoc -t html <(cat -) | lynx -stdin
+#mandoc <(pandoc -t man -f markdown <(cat -) )
+pandoc -t man -f markdown <(cat -) > out
+mandoc < out
+#pandoc -f markdown -t man <(cat -)

+ 84 - 74
vim/vimfiles/vimrc

@@ -97,6 +97,9 @@ set iskeyword-=_    " Don't skip over _
 " Search snippets
 set path+=~/daniel-markor/.app/snippets/**
 
+" Markdown to Mandoc
+nnoremap <LEADER>p :%!~/.termux/mdview.sh<CR>
+
 " Paste snippet
 function! Snippet(snip)
     execute 'find ' . a:snip . ' | execute ''norm ggVGy'' | bdelete | norm P'
@@ -156,7 +159,9 @@ function! RegisterSwapDefaultWith()
     endif
 endfunction
 nnoremap <Leader>c :call RegisterSwapDefaultWith()<CR>
+vnoremap <Leader>c y:call RegisterSwapDefaultWith()<CR>
 nnoremap <Leader>C :call RegisterSwapDefaultWith()<CR>+
+vnoremap <Leader>C y:call RegisterSwapDefaultWith()<CR>+
 "
 " (visual) <LEADER>ca := swap contents of default register (") with register a
 " (visual) <LEADER>C  := swap contents of default register with clipboard (+)
@@ -481,77 +486,82 @@ silent! call feedkeys(":nohlsearch\<CR>")
 
 set belloff=all
 
-iabbrev gen Genesis
-iabbrev ex Exodus
-iabbrev lev Leviticus
-iabbrev num Numbers
-iabbrev de Deuteronomy
-
-iabbrev jsh Joshua
-iabbrev jdg Judges
-iabbrev rut Ruth
-iabbrev 1sa 1 Samuel
-iabbrev 2sa 2 Samuel
-iabbrev 1kn 1 Kings
-iabbrev 2kn 2 Kings
-iabbrev 1ch 1 Chronicles
-iabbrev 2ch 2 Chronicles
-iabbrev ezr Ezra
-iabbrev neh Nehemiah
-iabbrev est Esther
-
-iabbrev job Job
-iabbrev ps Psalm
-iabbrev pr Proverbs
-iabbrev ecc Ecclesiastes
-iabbrev song Song of Solomon
-iabbrev isa Isaiah
-iabbrev jer Jeremiah
-iabbrev lam Lamentations
-iabbrev eze Ezekiel
-iabbrev dan Daniel
-iabbrev hos Hosea
-iabbrev joe Joel
-iabbrev am Amos
-iabbrev ob Obadiah
-iabbrev jon Jonah
-iabbrev mic Micah
-iabbrev nah Nahum
-iabbrev hab Habakkuk
-iabbrev zep Zephaniah
-iabbrev hag Haggai
-iabbrev zech Zechariah
-iabbrev mal Malachi
-
-iabbrev mt Matthew
-iabbrev mk Mark
-iabbrev lk Luke
-iabbrev jn John
-
-iabbrev act Acts
-
-iabbrev rom Romans
-iabbrev 1co 1 Corinthians
-iabbrev 2co 2 Corinthians
-
-iabbrev gal Galatians
-iabbrev eph Ephesians
-iabbrev php Philippians
-iabbrev col Colossians
-iabbrev 1th 1 Thessalonians
-iabbrev 2th 2 Thessalonians
-iabbrev 1ti 1 Timothy
-iabbrev 2ti 2 Timothy
-iabbrev tit Titus
-iabbrev phm Philemon
-
-iabbrev heb Hebrews
-iabbrev jm James
-iabbrev 1pt 1 Peter
-iabbrev 2pt 2 Peter
-iabbrev 1jn 1 John
-iabbrev 2jn 2 John
-iabbrev 3jn 3 John
-iabbrev jud Jude
-
-iabbrev rev Revelation
+augroup bible
+  autocmd!
+  autocmd FileType markdown {
+    iabbrev <buffer> gen Genesis
+    iabbrev <buffer> ex Exodus
+    iabbrev <buffer> lev Leviticus
+    iabbrev <buffer> num Numbers
+    iabbrev <buffer> de Deuteronomy
+
+    iabbrev <buffer> jsh Joshua
+    iabbrev <buffer> jdg Judges
+    iabbrev <buffer> rut Ruth
+    iabbrev <buffer> 1sa 1 Samuel
+    iabbrev <buffer> 2sa 2 Samuel
+    iabbrev <buffer> 1kn 1 Kings
+    iabbrev <buffer> 2kn 2 Kings
+    iabbrev <buffer> 1ch 1 Chronicles
+    iabbrev <buffer> 2ch 2 Chronicles
+    iabbrev <buffer> ezr Ezra
+    iabbrev <buffer> neh Nehemiah
+    iabbrev <buffer> est Esther
+
+    iabbrev <buffer> job Job
+    iabbrev <buffer> ps Psalm
+    iabbrev <buffer> pr Proverbs
+    iabbrev <buffer> ecc Ecclesiastes
+    iabbrev <buffer> song Song of Solomon
+    iabbrev <buffer> isa Isaiah
+    iabbrev <buffer> jer Jeremiah
+    iabbrev <buffer> lam Lamentations
+    iabbrev <buffer> eze Ezekiel
+    iabbrev <buffer> dan Daniel
+    iabbrev <buffer> hos Hosea
+    iabbrev <buffer> joe Joel
+    iabbrev <buffer> am Amos
+    iabbrev <buffer> ob Obadiah
+    iabbrev <buffer> jon Jonah
+    iabbrev <buffer> mic Micah
+    iabbrev <buffer> nah Nahum
+    iabbrev <buffer> hab Habakkuk
+    iabbrev <buffer> zep Zephaniah
+    iabbrev <buffer> hag Haggai
+    iabbrev <buffer> zech Zechariah
+    iabbrev <buffer> mal Malachi
+
+    iabbrev <buffer> mt Matthew
+    iabbrev <buffer> mk Mark
+    iabbrev <buffer> lk Luke
+    iabbrev <buffer> jn John
+
+    iabbrev <buffer> act Acts
+
+    iabbrev <buffer> rom Romans
+    iabbrev <buffer> 1co 1 Corinthians
+    iabbrev <buffer> 2co 2 Corinthians
+
+    iabbrev <buffer> gal Galatians
+    iabbrev <buffer> eph Ephesians
+    iabbrev <buffer> php Philippians
+    iabbrev <buffer> col Colossians
+    iabbrev <buffer> 1th 1 Thessalonians
+    iabbrev <buffer> 2th 2 Thessalonians
+    iabbrev <buffer> 1ti 1 Timothy
+    iabbrev <buffer> 2ti 2 Timothy
+    iabbrev <buffer> tit Titus
+    iabbrev <buffer> phm Philemon
+
+    iabbrev <buffer> heb Hebrews
+    iabbrev <buffer> jm James
+    iabbrev <buffer> 1pt 1 Peter
+    iabbrev <buffer> 2pt 2 Peter
+    iabbrev <buffer> 1jn 1 John
+    iabbrev <buffer> 2jn 2 John
+    iabbrev <buffer> 3jn 3 John
+    iabbrev <buffer> jud Jude
+
+    iabbrev <buffer> rev Revelation
+}
+augroup END