Created
August 9, 2018 04:47
-
-
Save Mossman1215/649cc58cc77b4df87b90877812837515 to your computer and use it in GitHub Desktop.
Sync my work notes to google drive when saving
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun save-gdrive () | |
"Sync org file to GDrive with rclone." | |
(when (eq major-mode 'org-mode) | |
(shell-command-to-string "rclone sync $HOME/org/notes.org gdrive:notes.org") | |
(shell-command-to-string "rclone sync $HOME/org/notes.org_archive gdrive:notes.org_archive") | |
)) | |
(add-hook 'after-save-hook 'save-gdrive) | |
(defun load-gdrive () | |
"Sync org file from GDrive with rclone." | |
(when (eq major-mode 'org-mode) | |
(shell-command-to-string "rclone sync gdrive:notes.org $HOME/org/gdrive-notes.org") | |
(shell-command-to-string "cp $HOME/org/notes.org $HOME/org/notes.org.old") | |
(shell-command-to-string "diff $HOME/org/notes.org $HOME/org/gdrive-notes.org > $HOME/org/notes.patch") | |
(shell-command-to-string "patch $HOME/org/notes.org.old -i $HOME/org/notes.patch -o $HOME/org/notes.org") | |
)) | |
(add-hook 'org-mode-hook 'load-gdrive) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment