1

I know a numeric prefix will create (or switch to) a new eshell session with that number. Is there a way to assign a string instead of a number?

For example, normally I get the following:

*eshell*<1>
*eshell*<2>
*eshell*<3>
*eshell*<4>

I would like

*eshell*<project1/source>
*eshell*<project1/doc>
*eshell*<project2/source>
*eshell*<project2/doc>

I figure I can use counsel to quickly switch between a large number of eshells.

My ultimate goal is to have a command say eshell-dir. It will parse out the last 2 or 3 directories from default-directory and create the eshell string. Then I can either switch to that eshell session if it exists or I can open a new eshell session with the name eshell.

Even better yet if the name could use uniquify that would be amazing!

I figure if I get this to work, I can do 90% of my shell work in emacs which would be a huge plus for me.

  • I use the following way to rename buffers in general with C-mouse-1 in the mode line identification (i.e., the buffer name). I create a new eshell-buffer and rename so it afterwards. (defun mode-line-rename-buffer (e) "Just like 'rename-buffer' only do it with the buffer of the window of the clicked mode-line" (interactive "e") (let ((buf (window-buffer (posn-window (event-start e))))) (when buf (with-current-buffer buf (call-interactively 'rename-buffer))))) (define-key mode-line-buffer-identification-keymap (kbd "<mode-line> <C-mouse-1>") 'mode-line-rename-buffer) – Tobias Jul 22 '17 at 19:17
  • Can you give an example of what you want? Using a number is hardcoded into the eshell function, but you could easily write your own version that handles things differently. – Qudit Jul 22 '17 at 21:06
  • The question has been updated with an example. Thanks Qudit – eflanigan00 Jul 22 '17 at 21:14
  • You can try to implement your idea by yourself and if you encounter a problem, ask that one instead. – xuchunyang Jul 24 '17 at 14:17
  • That was the plan but I got stuck on the string assignment of the name. I will read the blog posted below and try some things. I will post back my findings. – eflanigan00 Jul 24 '17 at 14:45
1

there is a nice blog article about eshell here : http://www.howardism.org/Technical/Emacs/eshell-fun.html

In this post, he describes a function named "eshell-here". I think you can basically adapt it by using uniquify.

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.