Try to fix terminal stuff
This commit is contained in:
@@ -2991,89 +2991,93 @@ Actually, return the method name."
|
||||
(not (my/dir-distrobox-p dir))
|
||||
(not (my/dir-sudo-p dir))))
|
||||
|
||||
;; eat
|
||||
(use-package eat
|
||||
:bind (("C-c V" . my/project-eat-or-default)
|
||||
:map eat-mode-map
|
||||
("M-o" . ace-window)
|
||||
:map eat-semi-char-mode-map
|
||||
("M-o" . ace-window)
|
||||
:map eat-eshell-emacs-mode-map
|
||||
("M-o" . ace-window)
|
||||
:map eat-eshell-semi-char-mode-map
|
||||
("M-o" . ace-window))
|
||||
:hook
|
||||
(eat-mode . my/-setup-eat-mode)
|
||||
:init
|
||||
(evil-define-key 'insert eat-semi-char-mode-map
|
||||
(kbd "<escape>") #'eat-self-input
|
||||
(kbd "C-S-n") #'evil-normal-state
|
||||
(kbd "C-y") #'eat-yank
|
||||
(kbd "C-u") #'universal-argument
|
||||
(kbd "C-w") evil-window-map)
|
||||
;; vterm
|
||||
(use-package vterm
|
||||
:bind (("C-c V" . my/project-vterm-or-default)
|
||||
:map vterm-mode-map
|
||||
("C-w" . evil-window-map))
|
||||
:hook ((vterm-mode . my/-setup-vterm-mode)
|
||||
(vterm-copy-mode . my/-setup-vterm-copy-mode))
|
||||
:config
|
||||
(defun my/-setup-eat-mode ()
|
||||
(visual-wrap-prefix-mode -1)
|
||||
(visual-line-mode -1))
|
||||
|
||||
;; The below makes sure that the first time the ESC key is pressed, it does
|
||||
;; what it is supposed to
|
||||
(add-hook 'eat--semi-char-mode-hook #'evil-normalize-keymaps)
|
||||
(defun my/-evil-disable-cursor-in-eat-buffer (oldfun &rest r)
|
||||
"Disable `evil--sw-refresh-cursor' in `eat-mode' buffers."
|
||||
(when (or (not (derived-mode-p 'eat-mode))
|
||||
(not (eq evil-state 'insert)))
|
||||
;; disable `evil--sw-refresh-cursor' in vterm buffers
|
||||
(defun my/-disable-evil--sw-refresh-cursor-in-vterm (oldfun &rest r)
|
||||
(unless (derived-mode-p 'vterm-mode)
|
||||
(apply oldfun r)))
|
||||
(advice-add 'evil--sw-refresh-cursor :around
|
||||
#'my/-evil-disable-cursor-in-eat-buffer)
|
||||
;; (defun my/-eat-update-cursor-on-tty (&rest r)
|
||||
;; (etcc--evil-set-cursor))
|
||||
;; (advice-add 'eat--set-cursor :after
|
||||
;; #'my/-eat-update-cursor-on-tty)
|
||||
(defun my/-eat-disable-evil-in-char-mode ()
|
||||
(if eat--char-mode
|
||||
(evil-local-mode -1)
|
||||
(evil-local-mode 1)))
|
||||
(add-hook 'eat--char-mode-hook #'my/-eat-disable-evil-in-char-mode)
|
||||
;; Evil fixes done
|
||||
#'my/-disable-evil--sw-refresh-cursor-in-vterm)
|
||||
|
||||
(defun my/-eat-choose-good-term ()
|
||||
(if (my/dir-really-remote-p)
|
||||
"xterm-256color"
|
||||
(eat-term-get-suitable-term-name)))
|
||||
(setq eat-term-name #'my/-eat-choose-good-term)
|
||||
(defun my/-eat-shell-for-cwd ()
|
||||
(defvar-local my/-vterm-pre-copy-mode-cursor nil
|
||||
"The cursor to restore after exiting `vterm-copy-mode'.")
|
||||
(defun my/-setup-vterm-copy-mode ()
|
||||
(if vterm-copy-mode
|
||||
(progn (setq my/-vterm-pre-copy-mode-cursor cursor-type)
|
||||
(evil-motion-state))
|
||||
(evil-emacs-state)
|
||||
(setq-local cursor-type my/-vterm-pre-copy-mode-cursor)))
|
||||
(evil-define-key 'motion vterm-copy-mode-map
|
||||
(kbd "i") #'vterm-copy-mode)
|
||||
(evil-set-initial-state 'vterm-mode 'emacs)
|
||||
(defun my/-setup-vterm-mode ()
|
||||
(visual-line-mode -1)
|
||||
(visual-wrap-prefix-mode -1))
|
||||
(defun my/-vterm-shell-for-cwd ()
|
||||
"Return a good shell for CWD, or nil if the default shell should be used."
|
||||
(cond
|
||||
((my/dir-container-p) "/bin/sh") ;; idk why zsh dosen't work
|
||||
((my/dir-really-remote-p) "/bin/sh")))
|
||||
(defun my/project-eat (&optional arg prompt)
|
||||
"Switch to or create a eat buffer in the current projects root."
|
||||
((my/dir-really-remote-p) "/bin/sh")
|
||||
(t shell-file-name)))
|
||||
(defun my/project-vterm (&optional arg prompt)
|
||||
"Switch to or create a vterm buffer in the current projects root."
|
||||
(interactive (list current-prefix-arg t))
|
||||
(if-let* ((proj (project-current prompt))
|
||||
(default-directory (project-root proj)))
|
||||
(let ((eat-buffer-name (format "*eat for project %s*" default-directory)))
|
||||
(eat (my/-eat-shell-for-cwd) arg))))
|
||||
(defun my/project-eat-or-default (&optional arg)
|
||||
"Open an eat for the current project, otherwise, open a normal eat."
|
||||
(let ((vterm-buffer-name (format "*vterm for project %s*" default-directory))
|
||||
(vterm-shell (my/-vterm-shell-for-cwd)))
|
||||
(vterm arg))))
|
||||
(defun my/project-vterm-or-default (&optional arg)
|
||||
"Open a vterm for the current project, otherwise, open a normal vterm."
|
||||
(interactive "P")
|
||||
(unless (my/project-eat arg)
|
||||
(eat (my/-eat-shell-for-cwd) arg))))
|
||||
(unless (my/project-vterm)
|
||||
(let ((vterm-shell (my/-vterm-shell-for-cwd)))
|
||||
(vterm arg)))))
|
||||
|
||||
;; eat stuff
|
||||
(use-package eat
|
||||
:pin nongnu
|
||||
:hook ((eat-mode . my/-setup-eat-mode)
|
||||
(eat--char-mode . my/-setup-eat--char-mode))
|
||||
:bind (:map eat-semi-char-mode-map
|
||||
("M-o" . ace-window))
|
||||
:config
|
||||
(defvar-local my/-eat-char-mode-evil-last-state nil
|
||||
"Evil state to restore after exiting `eat--char-mode'.")
|
||||
(defun my/-setup-eat--char-mode ()
|
||||
(cond
|
||||
(eat--char-mode
|
||||
(setq my/-eat-char-mode-evil-last-state evil-state)
|
||||
(evil-change-state 'emacs))
|
||||
(my/-eat-char-mode-evil-last-state
|
||||
(evil-change-state my/-eat-char-mode-evil-last-state))))
|
||||
(defun my/-setup-eat-mode ()
|
||||
(visual-line-mode -1)
|
||||
(visual-wrap-prefix-mode -1)))
|
||||
|
||||
;; eshell stuff
|
||||
(defvar eshell-mode-map)
|
||||
(use-package eshell
|
||||
:demand t
|
||||
:ensure nil
|
||||
:hook ((eshell-load . eat-eshell-visual-command-mode)
|
||||
:hook ((eshell-mode . my/-eshell-mode-setup)
|
||||
(eshell-mode . eat-eshell-mode)
|
||||
(eshell-mode . my/-eshell-mode-setup)
|
||||
(eshell-directory-change . my/-eshell-maybe-setup-remote))
|
||||
:bind (:map eshell-mode-map
|
||||
("TAB" . completion-at-point)
|
||||
("<tab>" . completion-at-point))
|
||||
:custom
|
||||
(eshell-history-append t)
|
||||
(eshell-destroy-buffer-when-process-dies t)
|
||||
:config
|
||||
(defvar eshell-command-aliases-list)
|
||||
(defun my/-eshell-filter-alias-list ()
|
||||
(cl-remove-if-not (lambda (elt)
|
||||
(or (string-match-p
|
||||
@@ -3244,18 +3248,18 @@ If no name is given, list all bookmarks instead."
|
||||
(set-face-attribute 'eshell-starship-icon-face nil
|
||||
:family "FiraCode Nerd Font"))
|
||||
|
||||
(defvar my/eshell-or-eat-hook nil
|
||||
"Hook to determine weather `my/open-shell-dwin' uses `eshell' or `eat'.")
|
||||
(defvar my/always-use-eat nil
|
||||
"Make `my/open-shell-dwim' always use eat.")
|
||||
(put 'my/always-use-eat 'safe-local-variable 'booleanp)
|
||||
(defvar my/eshell-or-vterm-hook nil
|
||||
"Hook to determine weather `my/open-shell-dwin' uses `eshell' or `vterm'.")
|
||||
(defvar my/always-use-vterm nil
|
||||
"Make `my/open-shell-dwim' always use vterm.")
|
||||
(put 'my/always-use-vterm 'safe-local-variable 'booleanp)
|
||||
(defun my/open-shell-dwim (&optional arg)
|
||||
"Open either an `eshell' or `eat' terminal based on `my/eshell-or-eat-hook'.
|
||||
"Open either an `eshell' or `vterm' terminal based on `my/eshell-or-vterm-hook'.
|
||||
ARG is the same as for either of the above functions."
|
||||
(interactive "P")
|
||||
(if (or my/always-use-eat
|
||||
(run-hook-with-args-until-success 'my/eshell-or-eat-hook))
|
||||
(my/project-eat-or-default arg)
|
||||
(if (or my/always-use-vterm
|
||||
(run-hook-with-args-until-success 'my/eshell-or-vterm-hook))
|
||||
(my/project-vterm-or-default arg)
|
||||
(my/project-eshell-or-default arg)))
|
||||
(keymap-global-set "C-c v" #'my/open-shell-dwim)
|
||||
|
||||
@@ -4312,3 +4316,7 @@ vising, and their major mode"
|
||||
(load loaddefs-file))
|
||||
|
||||
;;; init.el ends here
|
||||
|
||||
;; Local Variables:
|
||||
;; byte-compile-warnings: (not make-local)
|
||||
;; End:
|
||||
|
||||
Reference in New Issue
Block a user