Why Run Shell in Emacs
Advantage of Running Shell in Emacs
- You can copy, paste, edit, any part of shell output easily, to or from any buffer.
- You have full power of emacs to edit any line, regex search, or jump into any file path 〔see Emacs: Open File Path Under Cursor 💠〕, or using emacs abbrev system, etc.
- You don't have to leave emacs. No need to switch back and forth between emacs and terminal.
- Shell session is automatically logged (it doesn't scroll off the top). You can save the buffer anytime you want (Alt+x
write-file
), or close it, or run multiple shells, each runs in a buffer. No need to prepare to log a terminal session in advance. 〔see Linux: Record a Terminal Session, Logging Shell Output〕
Disadvantage of Running Shell in Emacs
- Run shell in emacs is slower. For very large compile job that prints lots output, better run in a dedicated terminal.
- Don't run shell in emacs for critical compile jobs. Emacs is pretty stable, but could crash, since there can be many things going on in emacs (email, irc, etc). When you build large software that takes long time by running shell in emacs, and if emacs crashed, it'd be a problem.
- Interactive commands may not work well. (e.g. ssh, complicated git command, apt-get, any tool from programing languages such as python, ruby irb ri gem, js npm, yarn, etc)
Some of the interactive software problems above can be solved by
Alt+x term
. But i don't recommend it because that introduces other complexities. For one thing, your normal emacs keys don't work anymore.
I run common daily unix commands in emacs shell. But for installing something new (e.g. ruby/python/js package manager), or some new 3rd party unix command i've never used before, i goto a dedicated terminal app to avoid complexity/confusion.
💡 TIP: Use Dired for Basic Shell Tasks
For common commands, such as copy, move, find, search file, you should do them all in dired .