dotfiles

personal dotfiles
git clone anongit@rnpnr.xyz:dotfiles.git
Log | Files | Refs | Feed | Submodules

Commit: 39f0b3177ecb685c0913bc20a38727b1cff71a69
Parent: 3eb312ea58e1bd1f14f7cbdf245b159b581b3035
Author: Randy Palamar
Date:   Mon, 27 Mar 2023 07:17:29 -0600

vis: move gpg.lua to its own repo

Diffstat:
D.config/vis/gpg.lua | 55-------------------------------------------------------
A.config/vis/plugins/vis-gpg | 1+
M.config/vis/visrc.lua | 2+-
M.gitmodules | 3+++
4 files changed, 5 insertions(+), 56 deletions(-)

diff --git a/.config/vis/gpg.lua b/.config/vis/gpg.lua @@ -1,55 +0,0 @@ -require('util') - -gpg = { key = 0 } - -local function decrypt(file) - local f, e = util:splitext(file.name) - if e ~= '.gpg' then return end - - local err, ostr, estr = vis:pipe(file, {start = 0, finish = file.size}, "gpg -d") - if err ~= 0 then return false end - - local i = estr:find("ID") - local j = estr:find(",", i) - local keyid = estr:sub(i+3, j-1) - if keyid ~= gpg.key then - vis:info(estr:gsub("\n[ ]*", " ")) - gpg.key = keyid - end - - file:delete(0, file.size) - file:insert(0, ostr) - file.modified = false - return true -end -vis.events.subscribe(vis.events.FILE_OPEN, decrypt) -vis.events.subscribe(vis.events.FILE_SAVE_POST, decrypt) - -local function encrypt(file, path) - local f, e = util:splitext(file.name) - if e ~= '.gpg' then return end - - if gpg.key == 0 then - vis:info('encrypt: keyid not found. file not saved.') - return false - end - - local tfn = os.tmpname() - local cmd = "gpg --yes -o " .. tfn .. " -e -r " .. gpg.key - local err, ostr, estr = vis:pipe(file, {start = 0, finish = file.size}, cmd) - if err ~= 0 then - if estr then - vis:message(estr) - end - return false - end - - local tf = io.open(tfn, 'rb') - file:delete(0, file.size) - file:insert(0, tf:read("a")) - tf:close() - os.remove(tfn) - - return true -end -vis.events.subscribe(vis.events.FILE_SAVE_PRE, encrypt) diff --git a/.config/vis/plugins/vis-gpg b/.config/vis/plugins/vis-gpg @@ -0,0 +1 @@ +Subproject commit 3414783632b6351b28446cc818fa1ce5658dd3c8 diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua @@ -2,7 +2,7 @@ require('vis') require('util') require('build') require('macros') -require('gpg') +require('plugins/vis-gpg/vis-gpg') spell = require('plugins/vis-spellcheck') spell.default_lang = "en_US" diff --git a/.gitmodules b/.gitmodules @@ -40,3 +40,6 @@ [submodule ".config/mpv/scripts/mpv-toolbox"] path = .config/mpv/scripts/mpv-toolbox url = https://codeberg.org/NRK/mpv-toolbox.git +[submodule ".config/vis/plugins/vis-gpg"] + path = .config/vis/plugins/vis-gpg + url = git@github.com:rnpnr/vis-gpg.git