Saturday, May 14, 2016

Re: Vim and gpg

Hi egalua!

On Sa, 14 Mai 2016, egalua@gmail.com wrote:

>
> Hi,
> it makes many years that I am using vim to open a text file which is encrypted by gpg. To this aim, in my .vimrc I have the following:
>
> augroup encrypted
> " Support for transparent editing of gpg (symmetric) encrypted files
> au!
> " Make sure nothing is written to ~/.viminfo while editing an encrypted file.
> autocmd BufReadPre,FileReadPre *.asc,*.gpg set viminfo=
> " We don't want a swap file, as it writes unencrypted data to disk
> autocmd BufReadPre,FileReadPre *.asc,*.gpg set noswapfile
> " Switch to binary mode to read the encrypted file
> autocmd BufReadPre,FileReadPre *.asc,*.gpg set bin
> autocmd BufReadPre,FileReadPre *.asc,*.gpg let ch_save = &ch|set ch=2
> autocmd BufReadPost,FileReadPost *.asc,*.gpg '[,']!gpg --decrypt 2> /dev/null
> " Switch to normal mode for editing
> autocmd BufReadPost,FileReadPost *.asc,*.gpg set nobin
> autocmd BufReadPost,FileReadPost *.asc,*.gpg set foldmethod=indent
> autocmd BufReadPost,FileReadPost *.asc,*.gpg hi Folded term=standout ctermfg=2 ctermbg=0
> autocmd BufReadPost,FileReadPost *.asc,*.gpg let &ch = ch_save|unlet ch_save
> autocmd BufReadPost,FileReadPost *.asc,*.gpg execute ":doautocmd BufReadPost " . expand("%:r")
> " Convert all text to encrypted text before writing
> autocmd BufWritePre,FileWritePre *.asc %!gpg -a -c 2>/dev/null
> autocmd BufWritePre,FileWritePre *.gpg %!gpg -c 2>/dev/null
> " Undo the encryption so we are back in the normal text, directly after the file has been written.
> autocmd BufWritePost,FileWritePost *.asc,*.gpg u
> augroup END
>
>
> All the above worked seamlessly throughout all the upgrades I made over the years to the underlying linux distribution.
> Up to now... :(
> Now I upgraded to Ubuntu 16.04 and there it does not work anymore.
> To be more precise, using plain vim (my preferred), sometime it works, but most of the times it doesn't and to help debugging I can add the following: when I open my file (say: vim r.txt.asc) the prompt I get is:
>
> "r.txt.asc" 100L, 6206C
> Enter passphrase:
>
> In this case, it doesn't work.
> Sometimes I get a different prompt, which looks like an error, that is:
>
> "r.txt.asc" 100L, 6206C
> ^[[2;2REnter passphrase:
>
> In these cases, it works!
>
> Does anybody have any hint?

Yeah, it looks like those terminal ansi escape sequences are sent to the
gpg program, therefore breaking your password. You might try with a
different terminal or trying, if any of those settings circumvents this
problem

:set term=builtin_ansi
:set t_RV=
:set t_u7=


Best,
Christian
--
Frage an Radio Eriwan: "Stimmt es, daß in den USA jeder ein Auto hat?"
Antwort: "Im Prinzip ja, aber bei uns hat dafür jeder einen Parkplatz."

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: