3

Many text editors will create temporary or backup files with the format <filename>~. Because of this, folders appear very cluttered with tons of files duplicated in this way ( <original> & <original>~ many times over).

I'd like to specify that these kinds of auto-generated files have a prepended '.', so that they become hidden.

Any way to do this for the whole system? Or are these file name definitions always application specific?

  • Honestly, I personally turn this off. It is a really really bad way of storing backups, neither safe or secure. It's way better to use git (or other questioning software) for your text files and do daily backups on top of that. I've found this in default vim settings, set nobackup in .vimrc solves it. I think gedit does that too and has the setting as well. – cprn Nov 21 '15 at 16:33
  • @CyprianGuerra For actual backing up of data you're right, these are terrible, but I think they're just for "oops" stuff. It actually saved me a few days ago, accidentally deleted the wrong file but the ~<file> was there. It has its uses. I wrote a script that puts the . in front of those files to hide them, so they're not too annoying anymore. – Mike Dannyboy Nov 23 '15 at 19:19
  • It seems reasonable at glance but when you think about it... in a good workflow you should never rm a file that isn't backed up. And if this data is somehow important (assume passwords, for simplicity) and you just rm original_file without checking for .original_file~, then your data will be lying there for everyone with file read access to take. Also, if you've just deleted a file, it will probably be easy to restore (disk space shouldn't be overwritten). – cprn Nov 23 '15 at 19:33
0

This is very application-specific. The editor will have to be configured in such a way that it generates filenames with a prepended dot rather than a appended tilde. This may not be doable at all in some editors that only allows for specifying a backup suffix.

However, if your concern is about seeing the backup files, you can at least get ls to not list them.

With GNU ls (from the GNU coreutils), you may use the -B or --ignore-backups option. This will explicitly not list files matching *~. It is equivalent to -I '*~' or --ignore='*~'.

In your shell initialization file (~/.bashrc for bash), add either

alias ls='command ls -B'

or

function ls { command ls -B "$@"; }

Making the backup files not show up in file managers can probably be done as well, but how you accomplish this (if possible) depends on the file manager you use.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.