mirror of
				https://github.com/larstvei/dot-emacs.git
				synced 2025-11-04 01:20:11 +00:00 
			
		
		
		
	Try using vterm
This commit is contained in:
		
							parent
							
								
									5dc6ad0f7c
								
							
						
					
					
						commit
						80f221909c
					
				
							
								
								
									
										45
									
								
								init.org
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								init.org
									
									
									
									
									
								
							@ -219,6 +219,7 @@
 | 
				
			|||||||
             racket-mode          ; Major mode for Racket language
 | 
					             racket-mode          ; Major mode for Racket language
 | 
				
			||||||
             slime                ; Superior Lisp Interaction Mode for Emacs
 | 
					             slime                ; Superior Lisp Interaction Mode for Emacs
 | 
				
			||||||
             try                  ; Try out Emacs packages
 | 
					             try                  ; Try out Emacs packages
 | 
				
			||||||
 | 
					             vterm                ; A terminal via libvterm
 | 
				
			||||||
             which-key)))         ; Display available keybindings in popup
 | 
					             which-key)))         ; Display available keybindings in popup
 | 
				
			||||||
     (when (memq window-system '(mac ns))
 | 
					     (when (memq window-system '(mac ns))
 | 
				
			||||||
       (push 'exec-path-from-shell packages)
 | 
					       (push 'exec-path-from-shell packages)
 | 
				
			||||||
@ -842,38 +843,44 @@
 | 
				
			|||||||
   the [[Key bindings]] section.
 | 
					   the [[Key bindings]] section.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   #+BEGIN_SRC emacs-lisp
 | 
					   #+BEGIN_SRC emacs-lisp
 | 
				
			||||||
   (lexical-let ((last-shell ""))
 | 
					   (let ((last-vterm ""))
 | 
				
			||||||
     (defun toggle-shell ()
 | 
					     (defun toggle-vterm ()
 | 
				
			||||||
       (interactive)
 | 
					       (interactive)
 | 
				
			||||||
       (cond ((string-match-p "^\\*shell<[1-9][0-9]*>\\*$" (buffer-name))
 | 
					       (cond ((string-match-p "^\\vterm<[1-9][0-9]*>$" (buffer-name))
 | 
				
			||||||
              (goto-non-shell-buffer))
 | 
					              (goto-non-vterm-buffer))
 | 
				
			||||||
             ((get-buffer last-shell) (switch-to-buffer last-shell))
 | 
					             ((get-buffer last-vterm) (switch-to-buffer last-vterm))
 | 
				
			||||||
             (t (shell (setq last-shell "*shell<1>*")))))
 | 
					             (t (vterm (setq last-vterm "vterm<1>")))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     (defun switch-shell (n)
 | 
					     (defun switch-vterm (n)
 | 
				
			||||||
       (let ((buffer-name (format "*shell<%d>*" n)))
 | 
					       (let ((buffer-name (format "vterm<%d>" n)))
 | 
				
			||||||
         (setq last-shell buffer-name)
 | 
					         (setq last-vterm buffer-name)
 | 
				
			||||||
         (cond ((get-buffer buffer-name)
 | 
					         (cond ((get-buffer buffer-name)
 | 
				
			||||||
                (switch-to-buffer buffer-name))
 | 
					                (switch-to-buffer buffer-name))
 | 
				
			||||||
               (t (shell buffer-name)
 | 
					               (t (vterm buffer-name)
 | 
				
			||||||
                  (rename-buffer buffer-name)))))
 | 
					                  (rename-buffer buffer-name)))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     (defun goto-non-shell-buffer ()
 | 
					     (defun goto-non-vterm-buffer ()
 | 
				
			||||||
       (let* ((r "^\\*shell<[1-9][0-9]*>\\*$")
 | 
					       (let* ((r "^\\vterm<[1-9][0-9]*>$")
 | 
				
			||||||
              (shell-buffer-p (lambda (b) (string-match-p r (buffer-name b))))
 | 
					              (vterm-buffer-p (lambda (b) (string-match-p r (buffer-name b))))
 | 
				
			||||||
              (non-shells (cl-remove-if shell-buffer-p (buffer-list))))
 | 
					              (non-vterms (cl-remove-if vterm-buffer-p (buffer-list))))
 | 
				
			||||||
         (when non-shells
 | 
					         (when non-vterms
 | 
				
			||||||
           (switch-to-buffer (first non-shells))))))
 | 
					           (switch-to-buffer (car non-vterms))))))
 | 
				
			||||||
   #+END_SRC
 | 
					   #+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Don't query whether or not the ~shell~-buffer should be killed, just kill
 | 
					   Don't query whether or not the ~shell~-buffer should be killed, just kill
 | 
				
			||||||
   it.
 | 
					   it.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   #+BEGIN_SRC emacs-lisp
 | 
					   #+BEGIN_SRC emacs-lisp
 | 
				
			||||||
   (defadvice shell (after kill-with-no-query nil activate)
 | 
					   (defadvice vterm (after kill-with-no-query nil activate)
 | 
				
			||||||
     (set-process-query-on-exit-flag (get-buffer-process ad-return-value) nil))
 | 
					     (set-process-query-on-exit-flag (get-buffer-process ad-return-value) nil))
 | 
				
			||||||
   #+END_SRC
 | 
					   #+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Use zsh:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   #+BEGIN_SRC emacs-lisp
 | 
				
			||||||
 | 
					   (setq vterm-shell "/usr/local/bin/zsh")
 | 
				
			||||||
 | 
					   #+END_SRC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   I'd like the =C-l= to work more like the standard terminal (which works
 | 
					   I'd like the =C-l= to work more like the standard terminal (which works
 | 
				
			||||||
   like running =clear=), and resolve this by simply removing the
 | 
					   like running =clear=), and resolve this by simply removing the
 | 
				
			||||||
   buffer-content. Mind that this is not how =clear= works, it simply adds a
 | 
					   buffer-content. Mind that this is not how =clear= works, it simply adds a
 | 
				
			||||||
@ -1317,10 +1324,10 @@
 | 
				
			|||||||
  (define-key custom-bindings-map (kbd "C-c j")   'cycle-spacing-delete-newlines)
 | 
					  (define-key custom-bindings-map (kbd "C-c j")   'cycle-spacing-delete-newlines)
 | 
				
			||||||
  (define-key custom-bindings-map (kbd "C-c d")   'duplicate-thing)
 | 
					  (define-key custom-bindings-map (kbd "C-c d")   'duplicate-thing)
 | 
				
			||||||
  (define-key custom-bindings-map (kbd "<C-tab>") 'tidy)
 | 
					  (define-key custom-bindings-map (kbd "<C-tab>") 'tidy)
 | 
				
			||||||
  (define-key custom-bindings-map (kbd "M-`")     'toggle-shell)
 | 
					  (define-key custom-bindings-map (kbd "M-`")     'toggle-vterm)
 | 
				
			||||||
  (dolist (n (number-sequence 1 9))
 | 
					  (dolist (n (number-sequence 1 9))
 | 
				
			||||||
    (global-set-key (kbd (concat "M-" (int-to-string n)))
 | 
					    (global-set-key (kbd (concat "M-" (int-to-string n)))
 | 
				
			||||||
                    (lambda () (interactive) (switch-shell n))))
 | 
					                    (lambda () (interactive) (switch-vterm n))))
 | 
				
			||||||
  (define-key custom-bindings-map (kbd "C-c C-q")
 | 
					  (define-key custom-bindings-map (kbd "C-c C-q")
 | 
				
			||||||
    '(lambda ()
 | 
					    '(lambda ()
 | 
				
			||||||
       (interactive)
 | 
					       (interactive)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user