Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The nice thing about Emacs is how much it's open to modification. There are compatibility modes to make it work like other editors (eg. "evil mode" to make it work more like Vi, "cua mode" to use "normal" key combos instead of having to learn Emacs's, etc.). There are often a bunch of alternative ways to do things, which have their own pros and cons, so if something seems frustrating, it pays to Google around a little to see if there's another way.

For example, running a terminal can be done with `term` (b/w) or `ansi-term` (colour), which provide a pretty standard xterm-like terminal emulator, completely under the control of whatever shell you use (eg. bash). This is useful for screen-manipulating programs like ncurses-based UIs, but is awkward to manipulate as text (a bit like the awkward copy/paste functionality in screen and tmux).

There's also `shell`, which runs a regular shell (like bash), but Emacs keeps control of the screen. This makes it useless for curses-based UIs, but great for text manipulation. For example, rather than running a pipeline over and over, tweaking the output options, we can often just dump everything to stdout then play around with it using the full power of Emacs (search/replace, regexes, keyboard macros, lisp functions, etc.).

There's also `eshell`, which is like shell mode but instead of a regular shell like bash, it uses a custom shell written in Emacs Lisp. Eshell's strength is its integration with Emacs; for example, Emacs Lisp functions can be run just like commands and Emacs buffers (including shells!) can be treated as files, etc. Eshell's weakness compared to shell is that it can't do pipes.

Personally, I use mixture of shell and eshell, plus some handy Lisp functions eg. for spawning new shells instead of always switching back to the same one. I avoid term and ansi-term in favour of a separate st terminal though, since they're pretty slow to update and their lack of decent text manipulation makes them feel uncomfortably "un-Emacsish".



M-x shell

is so useful for searching for text strings in outputs. (when grep alone will not do) like all things emacs/ terminal its a little awkward when trying to use the control keys (up arrow, ^r) and they get captured by emacs and not the shell.


Amen, and throw in hi-lock and you can create arbitrary keyword highlighting (like any time the word "error" appears it's colored red). Great for tailing log files.


M-p is the replacement for up arrow


Which I bind to f6 for convenience.


I've never understood claims that function keys are convenient, but I guess it's because I don't use them that much.


I agree that they are less convenient than the control key sequence, but better than the up arrow trick.

And it is a little worse on the kinesis, as the function keys are not the same quality as the rest of the keys.


have you tried multi-term (http://www.emacswiki.org/emacs/MultiTerm) it is much nicer than the canonical shell that is available...


I've only used eshell casually, but /dev/clip for redirecting output to the clipboard was really handy. It turns out there's a bunch of ways to do this, but eshell was my first exposure to clipboard as file.

It's also kinda nice setting up emacs in a cygwin that winds up being relatively consistent with mac.


Also redirect to buffer : ls >> #<buffer scratch>

(warning stars are turned into formatting in HN)

with C-c M-b to pick a buffer name easily


Another shortcoming of eshell is the still-incomplete manual.

https://www.gnu.org/software/emacs/manual/html_mono/eshell.h...


> Eshell's weakness compared to shell is that it can't do pipes.

I thought eshell had both pipes and output redirection but lacked input redirection.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: