Is there a way to pass non-numeric argument to functions?
Ex: C-u 5 M-x eshell makes(switches to) a eshell with name *eshell*<5>. But I want to give a name instead of number to eshell buffer.
I don't think there is any general way to pass non-numeric arguments to any command the same way C-u works.
However, different modes can get input using the minibuffer. For example, C-u M-x shell (rather than eshell) lets you name your new shell buffer.
You can easily write your own eshell command that also lets you name the buffer:
(defun eshell-new-buffer (name)
(interactive "sBuffer name:")
(eshell t)
(rename-buffer name))
Then bind it to some key:
(global-set-key (kbd "C-c e") 'eshell-new-buffer)
Now when you type C-c e, you will be prompted for a buffer name and a new eshell buffer with that name will be created for you.
Edit: Simplified the code as @sanityinc helpfully pointed out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With