term.el 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ;; https://github.com/syl20bnr/spacemacs/issues/6181
  2. ;; Avoid 2 second delay in emacsclient startup with Emacs 24.3.50+ and GNU screen
  3. ;;
  4. ;; (eval-after-load "xterm" ;; term/xterm.el does not provide 'xterm
  5. ;; '(defadvice xterm--query (around tweak-for-gnu-screen (query handlers) activate)
  6. ;; ;; GNU screen does not support this sequence
  7. ;; (unless (string= query "\e]11;?\e\\")
  8. ;; ad-do-it)))
  9. ;;
  10. (setq-default xterm-query-timeout nil)
  11. (setq terminal-here-scrollbar nil)
  12. (setq terminal-here-terminal-emulators (list "alacritty" "xterm"))
  13. (setq-default terminal-here-project-root-function #'projectile-project-root)
  14. (setq terminal-here-multiplexers '("tmux" "screen"))
  15. (defun wi-shell-current-dir ()
  16. "Open shell in current buffer directory."
  17. (interactive)
  18. (shell (concat "*shell " default-directory "*")))
  19. (defun wi-shell-cd-current-dir ()
  20. "Invoke shell and cd to `default-directory'."
  21. (interactive)
  22. (let ((dir default-directory))
  23. (shell)
  24. (insert "cd " dir)
  25. (comint-send-input)))
  26. (add-hook 'shell-mode-hook
  27. (lambda ()
  28. (progn (setq paragraph-separate "[ ]*$")
  29. (setq paragraph-start " \\|[ ]*$"))))
  30. (add-hook 'shell-mode-hook
  31. (lambda ()
  32. (set-process-query-on-exit-flag (get-process "shell") nil)))
  33. (add-hook 'eshell-mode-hook 'eshell-bookmark-setup)
  34. ;; (add-hook 'comint-output-filter-functions
  35. ;; 'comint-truncate-buffer)
  36. (with-eval-after-load 'vterm
  37. (let ((map vterm-mode-map))
  38. (define-key map (kbd "<S-prior>") 'scroll-down-command)
  39. (define-key map (kbd "<S-next>") 'scroll-up-command)
  40. (define-key map (kbd "C-u") 'vterm-send-C-u)
  41. (define-key map (kbd "C-y") 'vterm-send-C-y)
  42. (define-key map (kbd "<C-backspace>") 'vterm-send-backspace)
  43. (define-key map (kbd "<menu>") 'vterm-copy-mode)
  44. (define-key map (kbd "M-/") 'vterm-dabbrev-expand)
  45. (define-key map (kbd "S-<right>") 'multi-vterm-next)
  46. (define-key map (kbd "S-<left>") 'multi-vterm-prev))
  47. (let ((map vterm-copy-mode-map))
  48. (define-key map (kbd "<menu>") 'vterm-copy-mode))
  49. (push (list "find-file-below"
  50. (lambda (path)
  51. (if-let* ((buf (find-file-noselect path))
  52. (window (display-buffer-below-selected buf nil)))
  53. (select-window window)
  54. (message "Failed to open file: %s" path))))
  55. vterm-eval-cmds))
  56. (defun wi-vterm-prettify-symbols ()
  57. (set (make-local-variable 'prettify-symbols-alist)
  58. (append `(("&&" . ?∧)
  59. ("||" . ?∨)
  60. ("++" . ?⧺)
  61. ("<=" . ?≤)
  62. (">=" . ?≥)
  63. ("->" . ?→))
  64. mjru-prettify-hosts)))
  65. (add-hook 'vterm-mode-hook 'wi-vterm-prettify-symbols)
  66. (add-hook 'vterm-mode-hook 'goto-address-mode)
  67. (add-hook 'vterm-mode-hook 'guix-prettify-mode)
  68. (add-hook 'vterm-mode-hook 'emojify-mode)
  69. (setq vterm-max-scrollback 100000)
  70. (setq vterm-min-window-width 110)
  71. (defun vterm-dabbrev-expand-wrapper ()
  72. (save-current-buffer
  73. (setq-local buffer-read-only nil)
  74. (call-interactively #'dabbrev-expand)
  75. (thing-at-point 'symbol)))
  76. (defun vterm-dabbrev-expand ()
  77. (interactive)
  78. (if (thing-at-point 'symbol)
  79. (progn (vterm-send-C-w)
  80. (vterm-send-string (vterm-dabbrev-expand-wrapper) t))
  81. (vterm-send-string (vterm-dabbrev-expand-wrapper) t)))
  82. ;;;
  83. ;;; shell
  84. ;;;
  85. (setq shell-kill-buffer-on-exit t)