Emacs: Run Shell in Emacs

By Xah Lee. Date: . Last updated: .

Start Shell in Emacs

Alt+x shell.

When in shell, to run the previous shell command, press Ctrl+.

emacs shell 2022-06-02
Alt+x shell in Windows

Start a Second Shell in Emacs

Ctrl+u Alt+x shell

Call a shell command once

Alt+x shell-commandAlt+!】 to run a single shell command.

Send text selection to a shell command

Select a region, then Alt+x shell-command-on-regionAlt+|】.

For example, select a region, then type Alt+| wc -l Enter. This will print line count of region.

You can have the result replace the selected region. To do that, do universal-argumentCtrl+u】 before calling the shell on region command.

My shell doesn't work in Windows?

Most problems are probably caused by incorrect environment variable setup. See: Emacs in Microsoft Windows FAQ.

Shell in Emacs


Emacs Tutorial

Quick Start

Font

Split Window

File

Buffer

Copy/Paste

Find Replace

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc