8

A buffer can be renamed with rename-buffer command.

Is it possible to rename buffers from IBuffer?

A use case is to rename a bunch of Term buffers from Ibuffer.
The default name for Term buffers is *terminal*.

nephewtom
  • 2,219
  • 17
  • 29
  • 2
    I couldn't find any command in ibuffer to rename a buffer to a specified name (`R` tries to give buffer an unique name, and that's the closest thing to it.) However, `% m` allows to mark by a regexp that matches the mode name, and `* M` marks all buffers with a specified major mode. It seems that `rename-buffer` isn't bound to anyhting in ibuffer, and without binding it yourself, you'd have to call it with `M-x rename-buffer`. –  May 24 '17 at 15:15
  • 2
    See `define-ibuffer-op` and `ibuffer-do-rename-uniquely`. – politza May 24 '17 at 15:27

1 Answers1

2

You could try the following:

(define-ibuffer-op ibuffer-do-rename ()
  "Prompt for a new name for the selected buffers."
  (:opstring "renamed")
  (let* ((buffer-name (buffer-name buf))
         (new-name    (read-from-minibuffer "Rename buffer: "
                                            buffer-name)))
   (with-current-buffer buf
     (rename-buffer new-name))))

(eval-after-load "ibuffer"
  '(progn
     (define-key ibuffer-mode-map [?Z]    'ibuffer-do-rename)))
Brian
  • 21
  • 2