VIM stuff to be added as scripts
This commit is contained in:
45
vim/vimcrypted
Executable file
45
vim/vimcrypted
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Unsecure implementation of a simple encrypted file editor
|
||||
# The file is saved IN PLAIN TEXT when editing,
|
||||
# this script only takes care of storing the file
|
||||
# encrypted
|
||||
|
||||
|
||||
if [ ! -f "$1" ]
|
||||
then
|
||||
echo "Give me an encrypted text file"
|
||||
exit 1
|
||||
fi
|
||||
unc=($(echo "$1" | sed 's/.gpg$//'))
|
||||
if [ "$1" = "$unc" ]
|
||||
then
|
||||
echo "source is not .gpg"
|
||||
exit 1
|
||||
fi
|
||||
if [ -e "$unc" ]
|
||||
then echo "$unc already exists. exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gpg --decrypt "$1" > "$unc"
|
||||
|
||||
edit=`date +%s -r $unc`
|
||||
if [ -s "$unc" ]
|
||||
then vim -i NONE -n "$unc"
|
||||
else echo Error in decrypting
|
||||
rm "$unc"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
afteredit=`date +%s -r "$unc"`
|
||||
|
||||
if (( $edit != $afteredit ))
|
||||
then
|
||||
cat "$unc" | gpg -ca > "$1".tmp
|
||||
if [ -s "$1".tmp ]
|
||||
then mv "$1" "$1".old
|
||||
mv "$1".tmp "$1"
|
||||
fi
|
||||
fi
|
||||
rm "$unc"
|
||||
Reference in New Issue
Block a user