One small thing that has been bugging me with emacs
When opening a shell within a buffer i do:
M-x shell
So far so good
But if I want to open another shell, I switch to another buffer and:
C-u M-x shell
but this always opens in another window - not the one I am currently in
this is annoying does anyone know how to fix it?
EDIT
I should have added that i have multiple buffers open in multiple split windows, e.g. my frame is split into 3 sections - what i want is the new shell to open in the same section that currently has focus, i.e. the one i am typing in and not an alternate one
I think what happens when I do C-u M-x shell
is that the new shell buffer opens in the next window, i.e. the one you would shift to if you hit C-x o
. I want it to open in the same window
You can start an interactive shell in Emacs by typing M-x shell . By default, this will start the standard Windows shell cmd.exe . Emacs uses the SHELL environment variable to determine which program to use as the shell.
Much better to use the multiple buffer feature of emacs. If you are editing the first file and want to start editing the second file, simply use the hot key C-x C-f or the menu selection File->Open File to start the second file. The second file is loaded into its own buffer.
When you want to leave Emacs for a short time, type a C-z and Emacs will be suspended. To get back into Emacs, type %emacs at the shell prompt. To quit Emacs permanently, type C-x C-c.
Emacs comes with its own shell (as in, like bash or zsh ) written in entirely in Emacs-Lisp.
Emacs runs interactive shells in dedicated buffers. It cannot run a shell in, say, TeX buffer.
M-x shell creates a new shell if there isn't one already, and C-u M-x shell asks you for the name of a new buffer. You can also rename the shell buffer to facilitate multiple shells, see the link above.
EDIT: the new shell buffer is displayed using pop-to-buffer-same-window
(in Emacs24).
Your best venue is to add *Shell*
to display-buffer-alist
- but it is not necessary there.
In Emacs23 the display of the *Shell*
buffer is controlled by special-display-function
(since *Shell*
has a match in special-display-buffer-names
or special-display-regexps
). Set special-display-function
to display-buffer-same-window
(or something similar) and you should be golden.
However, the ultimate solution is to upgrade Emacs to v24; since you are on a linux system, it should be straightforward.
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