Auto-saving timestamped files

Hey Everyone!

I’m new to Kakoune and wondered if it contain any options for autosaving to a timestamped file, say once per hour and on each manual save?

As an example, say I’m editing todo.md then:

  1. It would autosave to todo.yyyy-mm-ddThh:mm.md every hour if the buffer had been edited, and
  2. Autosave again when manually saving the original.

I’m assuming that this could be configured somehow - so some pointers would be appreciated.

Thanks!!

Yo @oortarch,

The following shell script can probably work.

while :
do
	kak -clear
	kak -l |
	while read session
	do
		kak -p "$session" <<-'EOF'
			evaluate-commands -buffer ~/docs/todo.md %{
				write
				write %sh{date +~/docs/todo.%F_%R.md}
			}
		EOF
	done
	sleep 1h
done

For each manual save, you can add the following hook to your kakrc.

hook global BufWritePost ~/docs/todo.md %{
  write %sh{date +~/docs/todo.%F_%R.md}
}
1 Like