O'Reilly logo

Learning GNU Emacs, 3rd Edition by Bill Rosenblatt, Eric S. Raymond, Marc Loy, James Elliott, Debra Cameron

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Executing Commands in Shell Buffers

One of the most important features of Emacs is its ability to run a command shell in a buffer. Once you have started a shell buffer, you can do all of your normal command-line work within Emacs. What does this buy you?

  • You don’t have to leave Emacs to get a command prompt. If you want to print or compile a file that you’re editing, you can do it immediately.

  • You can use Emacs editing features to write your commands.

  • You can use Emacs editing features to “back up” through your command list, copy an old command, modify it, and execute it again.

  • You can save your shell buffer, keeping a transcript of your editing session—which automatically includes the output from every command that you ran. For debugging or remembering commands you run infrequently, this can be invaluable.

  • You can copy output from commands into a file or into another command.

  • You can save complex commands in a file and insert the file at the prompt, rather than retyping the command.

As you get used to working within Emacs, you will undoubtedly discover more and more ways to put shell mode to use.

In this section, we discuss shell mode. Later in this chapter, we discuss directory editing, printing, and calendar and diary features for doing simple time management in Emacs. Right now, we’ll start with a simple variation on shell mode, a feature that lets you execute commands one at a time.

Running One Command at a Time

To run a command while you’re in an Emacs session, type M-!. Emacs asks ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required