dev.fron.io nixrc / df917f3
emacs(vterm): cleanup term stuff Tony Olagbaiye a month ago
2 changed file(s) with 18 addition(s) and 64 deletion(s). Raw diff Collapse all Expand all
7676 :action #'vterm-shell-command
7777 :initial-input (or initial-input "")
7878 :history 'shell-command-history))
79 (add-hook 'after-init-hook
80 (lambda (&rest _)
81 (global-set-key (kbd "C-x M-&") #'ivy-term)))
79 (defalias #'ivy-vterm #'ivy-term)
80 (global-set-key (kbd "C-x M-&") #'ivy-term)
8281
8382 (provide 'scraps+shell)
8483 ;;; scraps+shell.el ends here
55 config = ''
66 (setq vterm-shell "${pkgs.xonsh.pname}")
77 (setq vterm-kill-buffer-on-exit t)
8 (defun vterm-shell-command (command)
9 (let ((vterm-shell command))
10 (vterm "*Vterm Shell Command*")))
811 (defun bqv/nested-emacs ()
912 (interactive)
10 (let ((vterm-shell "emacs -nw"))
11 (vterm "*nested-emacs*")))
12 (defun vterm-run (with-sudo &rest r)
13 (interactive "P")
14 (if with-sudo
15 (apply #'call-interactively (cons #'vterm--run-sudo r))
16 (apply #'call-interactively (cons #'vterm--run r))))
17 (defun vterm--run (command)
18 "Launch COMMAND in a vterm buffer."
19 (interactive (list (completing-read "Command" (mapcar #'file-name-base (executables-list)))))
20 (let* ((executable (car (split-string command " ")))
21 (buffer-name (concat "*" executable "*"))
13 (vterm-shell-command "*nested-emacs*"))
14
15 (defun vterm-run (with-sudo executable)
16 "Launch EXE in a vterm buffer, possibly WITH-SUDO."
17 ;(interactive (list (completing-read "Command" (mapcar #'file-name-base (executables-list)))))
18 (let* ((buffer-name (concat "*" executable "*"))
2219 (canonical-name (assoc executable (executables-list)
2320 '(lambda (exe) (= (file-name-base exe) )))))
2421 (assert (not (null executable)))
25 (let ((vterm-shell command))
22 (let ((vterm-shell (if with-sudo
23 (concat "sudo " executable)
24 executable)))
2625 (vterm buffer-name))))
27 (defun vterm-shell-command (command)
28 ;(interactive "sVTerm shell command: ")
29 (let ((vterm-shell command))
30 (vterm "*vterm-shell-command*")))
31 (global-set-key (kbd "C-x M-&") #'vterm-shell-command)
32 (defun vterm--run-sudo (command)
33 "Launch sudo COMMAND in a vterm buffer."
34 (interactive (list (completing-read "Command" (mapcar #'file-name-base (executables-list)))))
35 (let* ((executable (car (split-string command " ")))
36 (buffer-name (concat "*" executable "*"))
37 (canonical-name (assoc executable (executables-list)
38 '(lambda (exe) (= (file-name-base exe) )))))
39 (assert (not (null executable)))
40 (let ((vterm-shell (concat "sudo " command)))
41 (vterm buffer-name))))
42 (defun vterm-ssh-run (with-sudo &rest r)
26 (defun htop (&optional with-sudo)
4327 (interactive "P")
44 (if with-sudo
45 (apply #'call-interactively (cons #'vterm--ssh-run-sudo r))
46 (apply #'call-interactively (cons #'vterm--ssh-run r))))
47 (defun vterm--ssh-run (server command)
48 "Launch COMMAND over ssh to SERVER, in a vterm buffer."
49 (interactive (list (completing-read "Server" '("${hosts.wireguard.ipv4.zeta}"))
50 (completing-read "Command" (mapcar #'file-name-base (executables-list)))))
51 (let* ((executable (car (split-string command " ")))
52 (buffer-name (concat "*" executable "*"))
53 (canonical-name (assoc executable (executables-list)
54 '(lambda (exe) (= (file-name-base exe) )))))
55 (assert (not (null executable)))
56 (let ((vterm-shell (concat "ssh " server " -t " command)))
57 (vterm buffer-name))))
58 (defun vterm--ssh-run-sudo (server command)
59 "Launch sudo COMMAND over ssh to SERVER, in a vterm buffer."
60 (interactive (list (completing-read "Server" '("${hosts.wireguard.ipv4.zeta}"))
61 (completing-read "Command" (mapcar #'file-name-base (executables-list)))))
62 (let* ((executable (car (split-string command " ")))
63 (buffer-name (concat "*" executable "*"))
64 (canonical-name (assoc executable (executables-list)
65 '(lambda (exe) (= (file-name-base exe) )))))
66 (assert (not (null executable)))
67 (let ((vterm-shell (concat "ssh " server " -t sudo " command)))
68 (vterm buffer-name))))
69 (defun htop (with-sudo)
28 (vterm-run with-sudo "htop"))
29 (defun tuir (&optional with-sudo)
7030 (interactive "P")
71 (if with-sudo
72 (vterm--run-sudo "htop")
73 (vterm--run "htop")))
74 (defun tuir ()
75 (interactive)
76 (vterm--run "tuir"))
31 (vterm-run with-sudo "tuir"))
7732 '';
7833 systemDeps = with pkgs; [ cmake libtool libvterm ];
7934 };