dotfiles/bin/vim-recover

22 lines
459 B
Plaintext
Raw Normal View History

2019-05-03 09:45:06 +02:00
#!/usr/bin/env bash
2019-02-11 17:40:33 +01:00
# Check recovery directory from vim
2019-06-07 16:46:04 +02:00
if [ $# -lt 1 ]; then
echo -e >&2 "\033[31;1merror:\033[0m vim-recover expects an argument"
exit 1
fi
2019-02-11 17:40:33 +01:00
if [ -f $1 ]; then
2019-06-07 16:46:04 +02:00
echo -e >&2 "\033[31;1merror:\033[0m cannot recover an existing file"
exit 1
2019-02-11 17:40:33 +01:00
fi
2019-04-26 14:57:34 +02:00
backup_path=~/.nvim/backups/`echo $PWD/$1 | tr '/' '%'`
2019-02-11 17:40:33 +01:00
2019-04-26 14:56:39 +02:00
if [ ! -f "$backup_path" ]; then
2019-06-07 16:46:04 +02:00
echo -e >&2 "\033[31;1merror:\033[0m backup not found"
exit 2
2019-02-11 17:40:33 +01:00
fi
2019-04-26 14:56:39 +02:00
cp $backup_path $1