<commit_before>;;-------------------------------------------
;;; shell common
;;-------------------------------------------
(defun core--goto-max-with-emacs-state ()
  (interactive)
  (goto-char (point-max))
  (evil-emacs-state))

(defun core--set-work-state ()
  "ESC -> normal state; i/a/s.. -> emacs state"
  (shell-header-mode)
  (evil-set-initial-state major-mode 'emacs)
  (dolist (key '("i" "I" "a" "A" "s" "S" "c" "C"))
    (evil-local-set-key
     'normal key 'core--goto-max-with-emacs-state)))

;;-------------------------------------------
;;; eshell
;;-------------------------------------------
(defalias 'esh       #'multi-eshell)
(defalias 'eshell/e  #'find-file)
(defalias 'eshell/em #'find-file)
(defalias 'eshell/fo #'find-file-other-window)
(defalias 'eshell/d  #'dired)
(defalias 'eshell/do #'dired-other-window)

(add-hook 'eshell-load-hook
          (lambda ()
            (setq eshell-save-history-on-exit nil
                  eshell-buffer-shorthand     t
                  eshell-hist-ignoredups      t)))

(add-hook 'eshell-mode-hook
          (lambda ()
            (core/set-key eshell-mode-map
              :state 'emacs
              (kbd "C-r") 'counsel-esh-history
              (kbd "C-n") 'eshell-next-matching-input-from-input
              (kbd "C-p") 'eshell-previous-matching-input-from-input
              (kbd "C-u") 'eshell-kill-input
              (kbd "TAB") 'completion-at-point)

            ;; replace builtin clear
            (defun eshell/clear ()
              (interactive)
              (eshell/clear-scrollback))

            (core--set-work-state)))

;;; use eshell
(defun multi-eshell ()
  (interactive)
  (eshell t))

(defun eshell/b (&optional buffer)
  (interactive)
  (if buffer
      (switch-to-buffer buffer)
    (ivy-switch-buffer)))

(defun eshell/bo (&optional buffer)
  (interactive)
  (if buffer
      (switch-to-buffer-other-window buffer)
    (ivy-switch-buffer-other-window)))

;;-------------------------------------------
;;; comint
;;-------------------------------------------
(add-hook 'comint-mode-hook
          (lambda ()
            (core/auto-exit)
            (setq-local comint-prompt-read-only t)
            (setq-local comint-move-point-for-output 'others)
            (setq-local comint-history-isearch t)
            (core/set-key comint-mode-map
              :state 'emacs
              (kbd "C-n")    'comint-next-input
              (kbd "C-p")    'comint-previous-input
              (kbd "<up>")   'comint-next-input
              (kbd "<down>") 'comint-previous-input)
            (core--set-work-state)))

;;-------------------------------------------
;;; multi-term
;;-------------------------------------------
(require-package 'multi-term)

(setq multi-term-program "/bin/bash")

(defalias 'mt 'multi-term)
(autoload 'multi-term-prev "multi-term" nil t)
(autoload 'multi-term-next "multi-term" nil t)<commit_msg>添加comint交互模式的按键<commit_after>;;-------------------------------------------
;;; shell common
;;-------------------------------------------
(defun core--goto-max-with-emacs-state ()
  (interactive)
  (goto-char (point-max))
  (evil-emacs-state))

(defun core--set-work-state ()
  "ESC -> normal state; i/a/s.. -> emacs state"
  (shell-header-mode)
  (evil-set-initial-state major-mode 'emacs)
  (dolist (key '("i" "I" "a" "A" "s" "S" "c" "C"))
    (evil-local-set-key
     'normal key 'core--goto-max-with-emacs-state)))

;;-------------------------------------------
;;; eshell
;;-------------------------------------------
(defalias 'esh       #'multi-eshell)
(defalias 'eshell/e  #'find-file)
(defalias 'eshell/em #'find-file)
(defalias 'eshell/fo #'find-file-other-window)
(defalias 'eshell/d  #'dired)
(defalias 'eshell/do #'dired-other-window)

(add-hook 'eshell-load-hook
          (lambda ()
            (setq eshell-save-history-on-exit nil
                  eshell-buffer-shorthand     t
                  eshell-hist-ignoredups      t)))

(add-hook 'eshell-mode-hook
          (lambda ()
            (core/set-key eshell-mode-map
              :state 'emacs
              (kbd "C-r") 'counsel-esh-history
              (kbd "C-n") 'eshell-next-matching-input-from-input
              (kbd "C-p") 'eshell-previous-matching-input-from-input
              (kbd "C-u") 'eshell-kill-input
              (kbd "TAB") 'completion-at-point)

            ;; replace builtin clear
            (defun eshell/clear ()
              (interactive)
              (eshell/clear-scrollback))

            (core--set-work-state)))

;;; use eshell
(defun multi-eshell ()
  (interactive)
  (eshell t))

(defun eshell/b (&optional buffer)
  (interactive)
  (if buffer
      (switch-to-buffer buffer)
    (ivy-switch-buffer)))

(defun eshell/bo (&optional buffer)
  (interactive)
  (if buffer
      (switch-to-buffer-other-window buffer)
    (ivy-switch-buffer-other-window)))

;;-------------------------------------------
;;; comint
;;-------------------------------------------
(add-hook 'comint-mode-hook
          (lambda ()
            (core/auto-exit)
            (setq-local comint-prompt-read-only t)
            (setq-local comint-move-point-for-output 'others)
            (setq-local comint-history-isearch t)
            (core/set-key comint-mode-map
              :state 'emacs
              (kbd "C-n")    'comint-next-input
              (kbd "C-p")    'comint-previous-input
              (kbd "<up>")   'comint-next-input
              (kbd "<down>") 'comint-previous-input
              (kbd "C-l")    'comint-clear-buffer
              (kbd "C-u")    'comint-kill-input)
            (core--set-work-state)))

;;-------------------------------------------
;;; multi-term
;;-------------------------------------------
(require-package 'multi-term)

(setq multi-term-program "/bin/bash")

(defalias 'mt 'multi-term)
(autoload 'multi-term-prev "multi-term" nil t)
(autoload 'multi-term-next "multi-term" nil t)
{'fraction_non_alphanumeric': 0.2646860229574612, 'fraction_numerical': 0.0, 'mean_word_length': 1.4905422446406054, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2179055', 'n_tokens_mistral': 1945, 'n_tokens_neox': 1913, 'n_words': 347}