From 755cbd443621fab21c3a4679b16a33d8b1584f47 Mon Sep 17 00:00:00 2001 From: Nicholas Ochiel Date: Tue, 26 Sep 2017 23:52:11 +0300 Subject: [PATCH] Fix: glob for backup files. --- rc/extra/autorestore.kak | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rc/extra/autorestore.kak b/rc/extra/autorestore.kak index b6cb76999..af4e8c075 100644 --- a/rc/extra/autorestore.kak +++ b/rc/extra/autorestore.kak @@ -8,7 +8,9 @@ def autorestore-restore-buffer -docstring "Restore the backup for the current fi buffer_dirname=$(dirname "${kak_buffile}") ## Find the name of the latest backup created for the buffer that was open - backup_path=$(ls -1t ."${kak_bufname}".kak.* 2>/dev/null | head -n 1) + ## NB. kak doesn't automatically cd to current buffer_dirname. + buffer_backup_glob="${buffer_dirname}/.${buffer_basename}.kak.*" + backup_path=$(ls -1t ${buffer_backup_glob} 2>/dev/null | head -n 1) if [ -z "${backup_path}" ]; then exit @@ -16,6 +18,8 @@ def autorestore-restore-buffer -docstring "Restore the backup for the current fi printf %s\\n " ## Replace the content of the buffer with the content of the backup file + echo -debug \"Restoring file: ${backup_path}\" + exec -draft %{ %d!cat${backup_path}d } ## If the backup file has to be removed, issue the command once