Show long filenames in ibuffer

I have customized my ibuffer-format to have the name column width set to 36. This is fine in 99% of the filenames showing up there. However I also have to access a couple of files that have a common prefix that is longer then 36 characters. This way the files cannot be distinguished in ibuffer… Since I am not willing to have the width set to even higher value I have added this little defun to my init.el to deal with the issue:

 
(defun mp/ibuffer-show-filename ()
  (interactive)
  (let ((buf (ibuffer-current-buffer))
        (lsoutput nil))
    (when (file-exists-p (buffer-file-name buf))
      (with-temp-buffer
        (let* ((filename (buffer-file-name buf))
               (default-directory (file-name-directory filename))
               (just-filename (file-name-nondirectory filename)))
          (call-process "/usr/bin/ls" nil t nil "-l" just-filename)
          (setq lsoutput (buffer-substring-no-properties (point-min) (- (point-max) 1))))))
    (message lsoutput)))
 
(define-key ibuffer-mode-map (kbd "f") 'mp/ibuffer-show-filename)

This way I can stick to my column width of 36 and whenever I have need to see the a longer filename I can just press f on the entry and see the name at the bottom of the screen.

Ein Gedanke zu „Show long filenames in ibuffer“

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.