Comint Intercept: Combine shell/eshell/term mode

This is another Emacs package I developed recently to make my life better.

Comint Intercept


Intercept the input in comint-mode. This can be used to run eshell command, or run some command in a terminal buffer from the command line in shell buffer. That is, this is to combine the best part of shell, eshell and term mode. For example, you can run eshell `grep’ in the shell buffer, or when you run `top’ in the shell buffer, a terminal buffer is poped to run it. SSH is supported to run command remotely.


The preferred install method is through package manager: package.el. comint-intercept is available in MELPA package repository.

Or you can download the comint-intercept.el, add its path into Emacs load path, and load the file. For example, add

(add-to-list 'load-path "<directory of comint-intercept.el>")
(require 'comint-intercept)

in your Emacs init file.


A minor mode named comint-intercept-mode is defined. To toggle it in a shell buffer or some other comint mode buffer, you can run command comint-intercept-mode. Or you can enable comint-intercept-mode automatically when you create a new shell mode buffer via,

(add-hook 'shell-mode-hook 'comint-intercept-mode)

Then you can run eshell command via

$ e <eshell command>

Or run some eshell command directly via customizing comint-intercept-eshell-commands.

To run command in term mode, you can use

$ t <command> <args>...

Or run commands in term mode directly via customizing comint-intercept-term-commands.

If you want something more general, you can customize comint-intercept-pattern-actions, which is an alist maps input pattern (regexp) to action to take (function). The input string will be fed to the action function. Then you can process the input string via eshell-command or comint-intercept-term-command provided by the package.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s