summaryrefslogtreecommitdiff
path: root/modules/terminal-compat.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-01-23 22:42:10 -0600
committerCraig Jennings <c@cjennings.net>2026-01-23 22:42:10 -0600
commit7854ad74addd9bcae905def8fe4f844fb5c08678 (patch)
treefb1849fc4ebece45697c844eac4047a76ad984d1 /modules/terminal-compat.el
parentb62a9a792707581243b15116910d8aef33220d3f (diff)
fix(terminal): add console/mosh compatibility
- Create terminal-compat.el for arrow key escape sequences - Fix M-uppercase keybindings (M-O → M-S-o, etc.) that conflicted with terminal escape sequences ESC O A/B/C/D - Add GUI-only guards for emojify and icon rendering - 18 keybindings updated across 13 modules with override comments
Diffstat (limited to 'modules/terminal-compat.el')
-rw-r--r--modules/terminal-compat.el54
1 files changed, 54 insertions, 0 deletions
diff --git a/modules/terminal-compat.el b/modules/terminal-compat.el
new file mode 100644
index 00000000..f959646d
--- /dev/null
+++ b/modules/terminal-compat.el
@@ -0,0 +1,54 @@
+;;; terminal-compat.el --- Terminal compatibility fixes -*- lexical-binding: t; coding: utf-8; -*-
+;; author: Craig Jennings <c@cjennings.net>
+
+;;; Commentary:
+
+;; Fixes for running Emacs in terminal/console mode, especially over mosh.
+;; - Arrow key escape sequence handling
+;; - Disable graphical icons that show as unicode artifacts
+
+;;; Code:
+
+(require 'host-environment)
+
+(defun cj/terminal-compat-setup ()
+ "Set up terminal compatibility after init completes."
+ (when (env-terminal-p)
+ ;; Fix arrow key escape sequences for various terminal types
+ (define-key input-decode-map "\e[A" [up])
+ (define-key input-decode-map "\e[B" [down])
+ (define-key input-decode-map "\e[C" [right])
+ (define-key input-decode-map "\e[D" [left])
+
+ ;; Application mode arrows (sent by some terminals)
+ (define-key input-decode-map "\eOA" [up])
+ (define-key input-decode-map "\eOB" [down])
+ (define-key input-decode-map "\eOC" [right])
+ (define-key input-decode-map "\eOD" [left])))
+
+;; Run after init completes to override any package settings
+(add-hook 'emacs-startup-hook #'cj/terminal-compat-setup)
+
+;; Icon disabling only in terminal mode
+(when (env-terminal-p)
+ ;; Disable nerd-icons display (shows as \uXXXX artifacts)
+ (with-eval-after-load 'nerd-icons
+ (defun nerd-icons-icon-for-file (&rest _) "")
+ (defun nerd-icons-icon-for-dir (&rest _) "")
+ (defun nerd-icons-icon-for-mode (&rest _) "")
+ (defun nerd-icons-icon-for-buffer (&rest _) ""))
+
+ ;; Disable dashboard icons
+ (with-eval-after-load 'dashboard
+ (setq dashboard-display-icons-p nil)
+ (setq dashboard-set-file-icons nil)
+ (setq dashboard-set-heading-icons nil))
+
+ ;; Disable all-the-icons
+ (with-eval-after-load 'all-the-icons
+ (defun all-the-icons-icon-for-file (&rest _) "")
+ (defun all-the-icons-icon-for-dir (&rest _) "")
+ (defun all-the-icons-icon-for-mode (&rest _) "")))
+
+(provide 'terminal-compat)
+;;; terminal-compat.el ends here