Gedit
and medit
are two text editors that I know of that allow me to save a backup. So, if I create a file called temp.txt
the next time I edit it and then save it, I'll have a backup called temp.txt~
.
My question is this: is there a text editor that allows me to have backups named in a serial fashion so that I can have more than just the one backup in case I want to go back to the file as it existed a few revisions ago? For example, I'd have temp.txt
as the latest version and temp.bak.1
, temp.bak.2
, etc.?
If that is not possible, is there some script that will automatically rename a backup each time it is created so that serial versions are retained? Even a temp.timestamp.txt
would be great.
(I don't mind a solution using nano
as the text editor.)
I should clarify that I'm not a coder or programmer. I just want to have previous versions of text files that I edit. These text files maybe .css
or .rc
or .svg
files that form part of a theme. So if I edit some aspect of a theme's file, I can go back a bit in case I don't like a change I made.
Best Answer
There is a simple way to use mercurial for version control. First install it.
To configure mercurial make a file
~/.hgrc
with next content:If you use some mercurial servers, you can add more info to this file (read
man hgrc
).After that
cd
to directory with your text files. For example:You can add also any number of files. After we must init mercurial:
By default there's no files still, so we must to say mercurial, that we want to include all:
Now we make do simple commit:
Now do some fixes and see difference:
Now make another commit, after watch
hg log
: you will see both commits.To return to first commit just do so:
You see: a file is old.
Now restore last file:
Also you may do a simple script:
Run it when you start to edit your file, and it will check for changes every minute, if there was changes, mercurial will make new commit. Also, as I've mention in comments, you can use
at
orcron
for autocommits.