2

I'd like to have a copy of my .emacs file in my Dropbox folder but I'd also like to have this copy in an automatic way, I mean every time I change my .emacs in the home directory I want it to be instantly updated in the Dropbox directory (this necessity is because I want the .emacs to be equal in my windows and ubuntu partitions and I think Dropbox is a good tool for that). First I used the simple:

$ cp .emacs Dropbox/.emacs

then I tried using rsync (or gsync), well it works but I cannot grasp the difference between rsync and cp for this very simple backup. In fact, even if I have activated the option RSYNC_ENABLE=true in the rsync file, every time I modify the .emacs in my home I have to run the command rsync (or use gsync), as a cp, without having it automatically. How can I have it automatically?

Probably I'm missing something from the very basics of rsync.

Thanks for your help

3
  • and you are not using a symlink because?
    – Karthik T
    Nov 6, 2012 at 9:48
  • because I misunderstood rsync... Nov 6, 2012 at 9:54
  • 1
    ah ok, in that case, take a look at the answers, making a symlink is the standard way of doing what you want done.
    – Karthik T
    Nov 6, 2012 at 9:56

2 Answers 2

2

You're misunderstanding what rsync does. Unlike what the name suggests, it doesn't really sync anything on its own. It works almost the same as cp, except that it when it encounters the same file on the destination, it only updates it if it has changed. That is helpful when you're copying over a network, because it can save bandwidth. It does not, however, monitor files.

A better solution in your case is to move your .emacs directory to ~/Dropbox/.emacs, and have ~/.emacs be a symbolic link to it:

$ mv .emacs ~/Dropbox
$ ln -s ~/Dropbox/.emacs .emacs

Then you don't need any local syncing.

4
  • And then can I use the .emacs in Dropbox to copy it in windows and have the same emacs configuration even if it is a link? Nov 6, 2012 at 10:02
  • Exactly. A symbolic link acts (almost) exactly as if .emacs really is there. Of course, your next task is to make your Windows copy of Emacs find its configuration in the dropbox folder. That's beyond the scope of Ask Ubuntu :-)
    – Timo Kluck
    Nov 6, 2012 at 10:25
  • Thanks, the sync is now ok, I've only to figure out how create a symbolic link in windows :) Nov 6, 2012 at 13:22
  • lifehacker has instructions for windows as well
    – Karthik T
    Nov 6, 2012 at 16:10
1

The best answer for this is to use a symbolic link. Just do the following once

ln -sn ~/.emacs ~/Dropbox/.emacs

and it will create a link to ~/.emacs in Dropbox folder. This will be treated as a file by dropbox and synchronised. Every change you make to .emacs will automatically be synced by dropbox

6
  • And then can I use the .emacs in Dropbox to copy it in windows and have the same emacs configuration even if it is a link? Nov 6, 2012 at 10:00
  • Karthik, your arguments are wrong. You need to swap DropBox/.emacs and .emacs (and then I am assuming you're doing this in your homedir.
    – Lekensteyn
    Nov 6, 2012 at 10:02
  • it should work both ways right? or is this because of my ambiguous explanation?
    – Karthik T
    Nov 6, 2012 at 10:10
  • Does Dropbox dereference symbolic links? It won't really synchronize if you only share the symbolic link since that contains zero file contents. Before your edit, there would be an infinite loop when reading the symbolic link, but you've now fixed that.
    – Lekensteyn
    Nov 6, 2012 at 10:17
  • i dont remember offhand if ive done this before, and im away from my home so cant check, but lifehacker also suggests linking into the dropbox folder so i expect it works.
    – Karthik T
    Nov 6, 2012 at 10:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .