Multiple Emacs Shells
Posted by Rex under Development | Permalink | | Leave A Comment
Sometimes instead of running several sessions of SSH’s or putty’s, I run Emacs with multiple shells– this cuts down on the number of windows I have to deal with.
To run a shell in Emacs, you invoke the Lisp function “shell
” via meta-x shell
. This creates a buffer called *shell*
. Running it the second time though doesn’t create a 2nd shell buffer as you might expect, instead it brings you back to the original shell buffer. The trick is to rename the original buffer to avoid name collision. The quickest way to do this is via “rename-uniquely" function via
meta-x rename-uniquely
. It renames the buffer to a similar but unique name like "*shell*<2>
“. Now if you start another shell.
The better behavior is for Emacs to automatically create new buffer with unique name. Perhaps there’s a hook to configure this that somebody can point me to.
You should check out screen util http://www.bangmoney.org/presentations/screen.html
I installed a package “fshell” to solve the same need of renaming a shell. It allows you to use the universal argument (ie “C-u 2” “M-x fshell”, will create a shell(2))
It’s slightly faster in my opinion, I’m always trying to speed things up in emacs, cause I work with a ssh-tunneled emacs and the latency is a limiting factor.
regards.
Thanks guys, I’ll check out both fshell & screen.
hey Rex,
on how to speed up the opening of extra shells using fshell, I just came out with this simple lisp for my .emacs:
(defalias ‘forth
(read-kbd-macro “C-4 M-x fshell RET”))
(global-set-key [C-f4] ‘forth)
(defalias ‘fifth
(read-kbd-macro “C-5 M-x fshell RET”))
(global-set-key [C-f5] ‘fifth)
… and so on
For me it’s easier to use the direct shortcut “C-f4” than to input the argument 4 (C-u 4) and then type M-x fshell
Just wanted to share that little tip!
Thanks Ignacio, I’ll definitely give fshell a gander!