summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2026-10-24 17:45:10 +0100
committerjao <jao@gnu.org>2026-10-24 17:45:10 +0100
commitd4167b62750b002dc0e1af219460375160a0e9d0 (patch)
tree2d8ed5c07ca0badea90766675e30623ccbd696be
parent1331c107a9edb1c7c4b4b902b83689d958a1b5ca (diff)
downloadelibs-d4167b62750b002dc0e1af219460375160a0e9d0.tar.gz
elibs-d4167b62750b002dc0e1af219460375160a0e9d0.tar.bz2
shell/term
-rw-r--r--init.el56
-rw-r--r--lib/eos/jao-shell.el70
2 files changed, 73 insertions, 53 deletions
diff --git a/init.el b/init.el
index c1b0b59..cbc0af6 100644
--- a/init.el
+++ b/init.el
@@ -364,7 +364,7 @@
:demand t
:init
(setq jao-themes-default-family (jao-d-l "Menlo" "Hack") ;; "RobotoMono Nerd Font"
- jao-themes-default-size (jao-d-l 10 9)
+ jao-themes-default-size (jao-d-l 10 10)
jao-themes-default-variable-pitch-family
(jao-d-l "Helvetica" "Iosevka Etoile")
jao-themes-default-variable-pitch-size (jao-d-l 12 9)))
@@ -422,7 +422,8 @@
jao-minibuffer-inactive-buffer-line-color
(jao-d-l "#dfdfdf" "grey65")))
(setq jao-minibuffer-adaptive-alignment nil
- jao-minibuffer-info-face-alt 'jao-themes-dimm)
+ ; jao-minibuffer-info-face-alt 'jao-themes-dimm
+ jao-minibuffer-info-face-alt 'default)
:commands (jao-minibuffer-add-variable
jao-minibuffer-refresh
jao-minibuffer-mode
@@ -1309,14 +1310,8 @@
;;;; shell modes
(setq sh-basic-offset 2)
;; translates ANSI colors into text-properties, for eshell
-(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
-(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
-(defvar jao-use-vterm nil)
-(defvar jao-use-eat nil)
-
(add-to-list 'display-buffer-alist
'("\\*Async Shell Command\\*" (display-buffer-no-window)))
-
;;;; eat
(use-package eat
:ensure t
@@ -1327,41 +1322,6 @@
;; (eshell-mode . eat-eshell-visual-command-mode))
:diminish ((eat-eshell-mode . "")))
-;;;; term
-(defvar-local jao-term--cmd nil)
-
-(defun jao-term--find (cmd)
- (seq-find (lambda (b)
- (with-current-buffer b
- (and (derived-mode-p 'eat-mode 'term-mode 'vterm-mode)
- (string= (or jao-term--cmd "") cmd))))
- (buffer-list)))
-
-(defun jao-exec-in-term (cmd &optional name)
- (interactive "SCommand")
- (require 'eat nil t)
- (cond ((and jao-use-vterm (fboundp 'jao-exec-in-vterm))
- (jao-exec-in-vterm cmd name))
- (jao-use-eat (let ((eat-term-name "xterm-256color"))
- (with-current-buffer (eat cmd t)
- (setq-local jao-term--cmd cmd))))
- (t (ansi-term "bash" name)
- (set-process-sentinel (get-buffer-process (current-buffer))
- (lambda (process event)
- (when (string= event "finished\n")
- (kill-buffer (process-buffer process)))))
- (setq-local jao-term--cmd cmd)
- (term-send-string nil (concat cmd " ; exit\n")))))
-
-(defmacro jao-def-exec-in-term (name cmd &rest prelude)
- `(defun ,(intern (format "jao-term-%s" name)) (&optional term)
- (interactive "P")
- ,@prelude
- (let ((jao-use-vterm (if term (not jao-use-vterm) jao-use-vterm)))
- (if-let* ((b (jao-term--find ,cmd)))
- (pop-to-buffer b)
- (jao-exec-in-term ,cmd ,(format "*%s*" name))))))
-
;;;; eshell
;;;;; basic custom
(use-package eshell
@@ -1382,6 +1342,8 @@
(autoload 'ansi-color-apply "ansi-color")
;; (add-hook 'eshell-preoutput-filter-functions 'ansi-color-filter-apply)
(add-hook 'eshell-preoutput-filter-functions 'ansi-color-apply)
+(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
+(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(use-package eshell-syntax-highlighting
:after esh-mode
@@ -2108,15 +2070,13 @@
("k" (lambda () (concat "keyboard" (when (jao-x11-kb-toggled-p) "*")))
jao-x11-kb-toggle :if jao-x11-p)]]))
-(global-set-key (kbd "s-w") #'jao-transient-utils)
-
-(global-set-key (kbd "<f4>")
- (if (display-graphic-p) #'delete-frame #'jao-transient-utils))
-
;;; Global key bindings
(defun jao-global-keybindings ()
(interactive)
(global-set-key (kbd "<f2>") #'magit-status)
+ (global-set-key (kbd "<f4>") #'jao-transient-utils)
+ (global-set-key (kbd "<f5>") #'jao-weather)
+ (global-set-key (kbd "s-w") #'jao-transient-utils)
(global-set-key (kbd "C-x p") #'jao-prev-window)
(global-set-key (kbd "C-x o") 'other-window)
(global-set-key "\C-cj" #'join-line)
diff --git a/lib/eos/jao-shell.el b/lib/eos/jao-shell.el
index e13e07f..8745492 100644
--- a/lib/eos/jao-shell.el
+++ b/lib/eos/jao-shell.el
@@ -18,11 +18,70 @@
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
-;;; Commentary:
-
-;; shell helpers
-
-;;; Code:
+(require 'term)
+
+;;; term
+;;;###autoload
+(defvar jao-use-vterm nil)
+
+;;;###autoload
+(defvar jao-use-eat nil)
+
+(defvar-local jao-term--cmd nil)
+
+(defvar-local jao-term--cmd nil)
+
+(defun jao-term--find (cmd)
+ (seq-find (lambda (b)
+ (with-current-buffer b
+ (and (derived-mode-p 'eat-mode 'term-mode 'vterm-mode)
+ (string= (or jao-term--cmd "") cmd))))
+ (buffer-list)))
+
+(declare-function vterm nil)
+(declare-function vterm-mode nil)
+(defvar vterm-shell)
+(defvar vterm-kill-buffer-on-exit)
+
+(defun jao-exec-in-vterm (cmd bname &optional no-kill)
+ (if (string-blank-p (or cmd ""))
+ (vterm)
+ (let ((vterm-shell cmd)
+ (vterm-kill-buffer-on-exit (not no-kill))
+ (buff (generate-new-buffer bname)))
+ (switch-to-buffer buff)
+ (vterm-mode))))
+
+;;;###autoload
+(defun jao-exec-in-term (cmd &optional name no-kill)
+ (interactive "SCommand")
+ (require 'eat nil t)
+ (cond ((and jao-use-vterm (fboundp 'jao-exec-in-vterm))
+ (jao-exec-in-vterm cmd name no-kill))
+ ((and jao-use-eat (fboundp 'eat))
+ (let ((eat-term-name "xterm-256color"))
+ (with-current-buffer (eat cmd t)
+ (setq-local jao-term--cmd cmd))))
+ (t (ansi-term "bash" name)
+ (unless no-kill
+ (set-process-sentinel (get-buffer-process (current-buffer))
+ (lambda (process event)
+ (when (string= event "finished\n")
+ (kill-buffer (process-buffer process))))))
+ (setq-local jao-term--cmd cmd)
+ (term-send-string nil (format "%s%s\n" cmd (if no-kill "" ";exit"))))))
+
+;;;###autoload
+(defmacro jao-def-exec-in-term (name cmd &rest prelude)
+ `(defun ,(intern (format "jao-term-%s" name)) (&optional term)
+ (interactive "P")
+ ,@prelude
+ (let ((jao-use-vterm (if term (not jao-use-vterm) jao-use-vterm)))
+ (if-let* ((b (jao-term--find ,cmd)))
+ (pop-to-buffer b)
+ (jao-exec-in-term ,cmd ,(format "*%s*" name))))))
+
+;;; shell
(defun jao-shell-cmd-lines (cmd &rest args)
(let ((cmd (concat cmd " " (combine-and-quote-strings args))))
@@ -66,4 +125,5 @@
(defun jao-shell-kill-p (pr) (eq 0 (jao-shell-exec* t "killall" pr)))
(provide 'jao-shell)
+
;;; jao-shell.el ends here