5

Is there a way to get the output of git status --ignored in a Magit buffer? Preferably in a way that would make opening ignored files easy.

6

You can customize magit-status-sections-hook, functions in this hook are used to insert contents at magit status buffer.

;; Command to list ignored files:
;; $ git ls-files --others --ignored --exclude-standard --directory
(defun magit-ignored-files ()
  (magit-git-items "ls-files" "--others" "--ignored" "--exclude-standard" "-z" "--directory"))

(defun magit-insert-ignored-files ()
  (-when-let (files (magit-ignored-files))
    (magit-insert-section (ignored)
      (magit-insert-heading "Ignored files:")
      (magit-insert-un/tracked-files-1 files nil)
      (insert ?\n))))

then add magit-insert-ignored-files to magit-status-sections-hook, it should be very easy if using Custom. I added it right after the "Untracked files" section:

enter image description here

  • Oops, what version of Magit do I need for this to work? I've tried now and it removed the branch information from the status. – wvxvw Nov 7 '16 at 21:10
  • PS. When I change the order of hooks to put magit-insert-status-headers in the first position, then the branch information is displayed. – wvxvw Nov 7 '16 at 21:16
  • @wvxvw I am not sure, but it works good here by using latest version from Melpa (20161105.1602) and from Melpa-stable (2.8.0). – xuchunyang Nov 8 '16 at 3:57
  • The behavior I'm seeing is in version 20151211.2221. I'll update then and will see. – wvxvw Nov 8 '16 at 5:56

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.