0

I'm currently using emacs and iTerm. iTerm is driving me crazy simply because I cannot edit the text, and I'm falling asleep while trying to move the cursor from one end of a long command to the middle.

So, I would like to do terminal stuff with Emacs.

However, I feel like sticking to a separation of "terminal-world" and "programming-world".

I have a Mac OS command for switching to iTerm (from any window), which is what I would like to do in Emacs: from anywhere in the OS, press a key command and end up in a terminal in Emacs.

C-w in iTerm allows me to close a terminal, and C-t opens a new tab. Works well (though I thought how easy it will be in Emacs to just have something like "kill current terminal and spawn new one" in a single command).

Note that switching between buffers is also easy in iTerm, no chance to switch to a "useless" buffer (for a terminal) such as *scratch* or *messages*. I find them useful in programming-world, though.

Whenever I specifically go into Emacs, there my programming environment is ready.

How can I get the best of both worlds? I.e. keep them both separated and easily accessible, or set Emacs up such that both can live in the same space without hassle?

PascalVKooten
  • 20,643
  • 17
  • 103
  • 160
  • How about two programs running independently of each other? You can have a graphical version of Emacs running, either minimized or underneath, or sharing the screen real estate, or in a different work space. Same goes for iTerm. You can slowly wean yourself from iTerm and have buffers in Emacs dedicated to terminal related projects. You can have separate frames in Emacs dedicated to terminal projects. Check out frame-bufs by Alp Aker to associate certain buffers with specific frames. You may also be interested in elscreen or tabbar libraries for Emacs. – lawlist Apr 03 '15 at 14:25

2 Answers2

1

Regardless of whether you're using the Emacs GUI (recommended) or the terminal version and also regardless of whether you're using a fresh instance of Emacs or using emacsclient to connect to another instance in server or daemon mode, what you probably want is this:

M-x ansi-term

It will prompt you with your default shell, usually /bin/bash, press enter and you've got a complete shell in a buffer. The great thing here is you can replace the default shell with any similarly interactive thing you like and have it operate as you'd expect in a terminal. So in my case I periodically use that with the Python interpreter instead of bash. There are a couple of little quirks for swapping between more Emacs-like behaviour and more terminal-like behaviour, but otherwise. By default these are bound to C-c C-j and C-c C-k.

I suggest just playing with them for a while to get used to them. I ended up binding the M-x ansi-term bit to one of the function keys.

Ben
  • 3,981
  • 2
  • 25
  • 34
0

I use a lot emacs's shell-mode: http://wikemacs.org/wiki/Shell

I love that the shell buffer is like a regular emacs buffer, i.e.: it's all text. So I can

  • search in the buffer (or helm-swoop),
  • I can change font color of keywords on demand, etc.
  • I can make urls clickable
  • I can make file names clickable (super useful on compilation)
  • I can have shell completion better than zsh

I often use two tricks: the package shell-here to open a shell in the current directory (not sure if it is the normal behaviour now) and shell-pop, that pops up and out a shell window. In conjonction I heavily use elscreen to have more working areas. There's many more tips in the link, tell me what you think !

Ehvince
  • 17,274
  • 7
  • 58
  • 79