5 ms·
Heh, I tend to go all in and run shells in Emacs :) There are (at least) 3 ways to do this: - `term` and `ansi-term` act as terminal emulators; they run a nor
by chriswarbo 9y ago
Heh, I tend to go all in and run shells in Emacs :)
There are (at least) 3 ways to do this:
- `term` and `ansi-term` act as terminal emulators; they run a normal shell, like bash, and act much like e.g. `xterm`. You can even use curses-based programs. I don't use this as I find it quite clunky, since normal Emacs navigation and editing doesn't work (since the key combos would conflict with those used by the shell and applications).
- `eshell` is the opposite extreme: it's a shell which you use instead of bash and friends. It has nice features like piping to a buffer, running Elisp (if that's what you're into) and (my favourite) using TRAMP to invoke SSH and sudo. I tend not to use it much other than for TRAMP. The most obvious problem is the limited support for piping.
- `shell` is half way between. It runs a normal shell like bash, but Emacs keeps control over the buffer. This means we can't use things like curses, but we can navigate and edit the buffer contents just like any other.
Emacs `shell` is my "default" terminal; I currently have 24 shell buffers open. For things like curses, I use a separate `st` window running DVTM.
As a bonus, we can actually use `shell` and TRAMP together: we first use TRAMP to connect somewhere, e.g. `/ssh:me@remote:/home/me` (we can do this using `cd` in `eshell`, or using `dired` mode, or whatever), then from there we invoke `shell`. We'll be dropped into a remote shell, just as if we'd run `ssh`, but Emacs will be able to do things like tab-completion for the remote system.
- bdarnell 9y agoI'm also a fan of emacs shell and tramp, and use functions like this to start shells on remote boxes without the extra dired/whatever step: (defun shell-foo() (interactive) (let ((default-directory "/ssh:bdarnell@foo:/home/bdarnell/")) (shell "*shell-foo*")))
- juki 9y agoAlso when you just want to run a single command, `M-&` (`async-shell-command`) is always handy. Or in Dired mode `&` for operating on files. At least for me those two work for majority of shell usage.
- rekado 9y agoI mostly use `M-x shell`. One of the best features (other than the standard features of Emacs buffers) is `C-c C-p` and `C-c C-n` to jump to the previous/next prompt.
- gkya 9y agoOn that last bit, it's possible to have org links point to tramp URLs, so in my start.org file (my initial buffer, an entrance to my world :)) I keep some links to remotes I frequent, and with ssh agent running, it's one clock to connect. Also it's useful to be able to just link a related remote directory in my notes.