git に track されていないファイルを dired でマークする
必要にかられたので作成.表題の通り.
(defun dired-mark-git-untracked-files () "Mark files not tracked in git in current dired session" (interactive) (let ((untracked-files (make-hash-table :test 'equal)) (command (format "cd %s &&\ git ls-files --others" dired-directory))) (with-temp-buffer (flet ((message (&rest args) nil)) (shell-command command (current-buffer) (current-buffer))) (goto-char (point-min)) (while (not (eobp)) (puthash (buffer-substring (line-beginning-position) (line-end-position)) t untracked-files) (forward-line 1))) ;; In dired buffer (save-excursion (goto-char (point-min)) (while (not (eobp)) (condition-case nil (when (gethash (dired-get-filename t) untracked-files nil) (let ((inhibit-read-only t)) (forward-line 0) (delete-char 1) (insert dired-marker-char))) (error nil)) (forward-line 1)))))