Skip to content

tninja/send-to-shell.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

send-to-shell.el

A unified Emacs package for sending code to shell buffers with support for multiple backends: shell, vterm, eat, and ghostel.

./send_to_shell.png

Features

  • Multiple shell backends: Support for shell, vterm, eat, and ghostel
  • Buffer-specific shell buffers: Each source file gets its own dedicated shell buffer
  • Flexible code sending: Send selected regions or current blocks to shell
  • Minimal dependencies: Only depends on Emacs built-in packages (with optional shell backends)

Installation

Clone the repository and add to your Emacs load path:

(add-to-list 'load-path "~/.emacs.d/site-lisp/send-to-shell.el")
(require 'send-to-shell)

Usage

Main Command

The primary entry point for send-to-shell is the interactive command:

(send-to-shell)

This shows an interactive menu where you can select:

  • A shell backend (shell, vterm, eat, ghostel)
  • An action (start or switch to shell, send region or block, or send current line)

Core Functions

send-to-shell-send-region (start end backend)

Send a region of text to the specified shell backend.

(send-to-shell-send-region (point-min) (point-max) 'shell)

send-to-shell-send-block (backend)

Send the current paragraph/block to the specified shell backend.

(send-to-shell-send-block 'vterm)

send-to-shell-send-region-or-block (backend)

Send the active region if one exists, otherwise send the current block.

(send-to-shell-send-region-or-block 'shell)

send-to-shell-send-current-line (backend)

Send the current line to the specified shell backend.

(send-to-shell-send-current-line 'shell)

send-to-shell-start-shell (backend)

Start or switch to the shell buffer for the current source buffer. This command must be called from sh-mode.

(send-to-shell-start-shell 'shell)

Backend Management

List available backends:

(send-to-shell-get-available-backends)
;; Returns: (shell vterm eat ghostel) based on what's installed

Configuration

Set the default backend:

(setq send-to-shell-default-backend 'vterm)

Adjust sleep time for vterm (in milliseconds):

(setq send-to-shell-vterm-sleep-ms 150)

Buffer Naming

Each source buffer gets a dedicated shell buffer using the pattern *<source-buffer-name>*. For example:

  • script.sh → shell buffer *script.sh*
  • Makefile → shell buffer *Makefile*

Supported Backends

shell (Built-in)

Traditional comint-based shell. No external dependencies required.

vterm

Full terminal emulator. Requires emacs-libvterm package.

eat

Terminal emulator implementation. Requires eat package. The package is loaded on demand when available.

ghostel

Alternative terminal backend. Requires ghostel package.

Key Bindings

Add to your Emacs configuration to set up key bindings:

;; Open send-to-shell menu
(global-set-key (kbd "C-c C-s") 'send-to-shell)

;; Or register the built-in sh-mode bindings
(send-to-shell-register-sh-mode-keybindings)

;; Equivalent sh-mode bindings installed by the helper above:
;; C-c C-s -> send-to-shell
;; C-c C-z -> start or switch to shell
;; C-c C-n -> send current line
;; C-c C-c -> send region or block

When using the transient menu, the Start or switch to shell action selects the shell window after opening or switching to it.

License

See LICENSE file in the repository.

About

send shell command from .sh file to different type of shells

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors