在dired中使用rsync同步文件
下面这段代码是我很久以前从网上找到的(源地址似乎以及不能再访问了),我经常会用到这段代码:
;;;###autoload (defun ora-dired-rsync (dest) (interactive (list (expand-file-name (read-file-name "Rsync to:" (dired-dwim-target-directory))))) ;; store all selected files into "files" list (let ((files (dired-get-marked-files nil current-prefix-arg)) ;; the rsync command (tmtxt/rsync-command "rsync -arvz --progress ")) ;; add all selected file names as arguments ;; to the rsync command (dolist (file files) (setq tmtxt/rsync-command (concat tmtxt/rsync-command (shell-quote-argument file) " "))) ;; append the destination (setq tmtxt/rsync-command (concat tmtxt/rsync-command (shell-quote-argument dest))) ;; run the async shell command (async-shell-command tmtxt/rsync-command "*rsync*") ;; finally, switch to that window (other-window 1))) (define-key dired-mode-map "Y" 'ora-dired-rsync)
它能做到让你拷贝大量的文件和目录而不会卡住Emacs,而且还带了个进度条.
感谢你tmtxt,创建这段代码的神秘人. 希望还能再看到你重开博客.