@@ -141,9 +141,48 @@ Soft-wrapped newlines are automatically stripped from copied text.
141141- Prompt navigation via OSC 133 — jump between prompts with ` C-c C-n ` / ` C-c C-p `
142142- Title tracking (buffer renamed from OSC 2)
143143- OSC 8 hyperlinks — clickable URLs in terminal output (click or ` RET ` to open)
144+ - Elisp eval from shell via OSC 51 — call whitelisted Emacs functions from shell scripts
144145- OSC 52 clipboard support (opt-in, for remote sessions)
145146- ` INSIDE_EMACS ` and ` EMACS_GHOSTEL_PATH ` environment variables
146147
148+ ### Calling Elisp from the Shell
149+
150+ Shell scripts running inside ghostel can call whitelisted Elisp functions
151+ via the ` ghostel_cmd ` helper (provided by the shell integration scripts):
152+
153+ ``` sh
154+ ghostel_cmd find-file " /path/to/file"
155+ ghostel_cmd message " Hello from the shell"
156+ ```
157+
158+ This uses OSC 51 escape sequences (the same protocol as vterm). Only
159+ functions listed in ` ghostel-eval-cmds ` are allowed.
160+
161+ Default whitelisted commands:
162+
163+ ` find-file ` , ` find-file-other-window ` , ` dired ` , ` dired-other-window ` , ` message ` .
164+
165+ Add your own with:
166+
167+ ``` elisp
168+ (add-to-list 'ghostel-eval-cmds '("magit-status-setup-buffer" magit-status-setup-buffer))
169+ ```
170+
171+ Example shell aliases (add to your ` .bashrc ` / ` .zshrc ` ):
172+
173+ ``` sh
174+ if [[ " $INSIDE_EMACS " = ' ghostel' ]]; then
175+ # Open a file in Emacs from the terminal
176+ e () { ghostel_cmd find-file-other-window " $@ " ; }
177+
178+ # Open dired in another window
179+ dow () { ghostel_cmd dired-other-window " $@ " ; }
180+
181+ # Open magit for the current directory
182+ gst () { ghostel_cmd magit-status-setup-buffer " $( pwd) " ; }
183+ fi
184+ ```
185+
147186### Color Palette
148187
149188The 16 ANSI colors are defined as Emacs faces inheriting from ` term-color-* ` :
@@ -164,18 +203,19 @@ individual faces with `M-x customize-face`.
164203
165204## Configuration
166205
167- | Variable | Default | Description |
168- | -------------------------------| ---------------------| ----------------------------------------|
169- | ` ghostel-shell ` | ` $SHELL ` | Shell program to run |
170- | ` ghostel-shell-integration ` | ` t ` | Auto-inject shell integration |
171- | ` ghostel-buffer-name ` | ` "*ghostel*" ` | Default buffer name |
172- | ` ghostel-max-scrollback ` | ` 10000 ` | Maximum scrollback lines |
173- | ` ghostel-timer-delay ` | ` 0.033 ` | Redraw delay in seconds (~ 30fps) |
174- | ` ghostel-kill-buffer-on-exit ` | ` t ` | Kill buffer when shell exits |
175- | ` ghostel-enable-osc52 ` | ` nil ` | Allow apps to set clipboard via OSC 52 |
176- | ` ghostel-prompt-reapply-on-redraw ` | ` nil ` | Re-apply prompt markers after full redraws |
177- | ` ghostel-keymap-exceptions ` | ` ("C-c" "C-x" ...) ` | Keys passed through to Emacs |
178- | ` ghostel-exit-functions ` | ` nil ` | Hook run when the shell process exits |
206+ | Variable | Default | Description |
207+ | ------------------------------------| ---------------------| --------------------------------------------|
208+ | ` ghostel-shell ` | ` $SHELL ` | Shell program to run |
209+ | ` ghostel-shell-integration ` | ` t ` | Auto-inject shell integration |
210+ | ` ghostel-buffer-name ` | ` "*ghostel*" ` | Default buffer name |
211+ | ` ghostel-max-scrollback ` | ` 10000 ` | Maximum scrollback lines |
212+ | ` ghostel-timer-delay ` | ` 0.033 ` | Redraw delay in seconds (~ 30fps) |
213+ | ` ghostel-kill-buffer-on-exit ` | ` t ` | Kill buffer when shell exits |
214+ | ` ghostel-eval-cmds ` | ` (see above) ` | Whitelisted functions for OSC 51 eval |
215+ | ` ghostel-enable-osc52 ` | ` nil ` | Allow apps to set clipboard via OSC 52 |
216+ | ` ghostel-prompt-reapply-on-redraw ` | ` nil ` | Re-apply prompt markers after full redraws |
217+ | ` ghostel-keymap-exceptions ` | ` ("C-c" "C-x" ...) ` | Keys passed through to Emacs |
218+ | ` ghostel-exit-functions ` | ` nil ` | Hook run when the shell process exits |
179219
180220## Commands
181221
@@ -269,7 +309,7 @@ powering Neovim's built-in terminal.
269309| Alternate screen | Yes | Yes |
270310| Shell integration auto-inject | Yes | No |
271311| Prompt navigation (OSC 133) | Yes | Yes |
272- | Elisp eval from shell | No | Yes |
312+ | Elisp eval from shell | Yes | Yes |
273313| Tramp-aware directory | No | Yes |
274314| OSC 52 clipboard | Yes | Yes |
275315| Copy mode | Yes | Yes |
0 commit comments