diff options
Diffstat (limited to '')
-rw-r--r-- | emacs.d/core/core-term.el | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/emacs.d/core/core-term.el b/emacs.d/core/core-term.el new file mode 100644 index 0000000..19877c3 --- /dev/null +++ b/emacs.d/core/core-term.el @@ -0,0 +1,93 @@ +(use-package eshell + :ensure t + :defer t + :init + (progn + (setq eshell-cmpl-cycle-completions nil + ;; auto truncate after 20k lines + eshell-buffer-maximum-lines 20000 + ;; history size + eshell-history-size 350 + ;; no duplicates in history + eshell-hist-ignoredups t + ;; buffer shorthand -> echo foo > #'buffer + eshell-buffer-shorthand t + ;; my prompt is easy enough to see + eshell-highlight-prompt nil + ;; treat 'echo' like shell echo + eshell-plain-echo-behavior t) + + ;; Caution! this will erase buffer's content at C-l + (add-hook 'eshell-mode-hook + #'(lambda () + (define-key eshell-mode-map (kbd "C-l") 'eshell/clear)))) + :config + (progn + (require 'esh-opt) + + ;; quick commands + (defalias 'eshell/e 'find-file-other-window) + (defalias 'eshell/d 'dired) + (setenv "PAGER" "less") + + ;; support `em-smart' + (require 'em-smart) + (setq eshell-where-to-jump 'begin + eshell-review-quick-commands nil + eshell-smart-space-goes-to-end t) + (add-hook 'eshell-mode-hook 'eshell-smart-initialize) + + ;; Visual commands + (require 'em-term) + (mapc (lambda (x) (push x eshell-visual-commands)) + '("el" "elinks" "htop" "less" "ssh" "tmux" "top")) + + ;; automatically truncate buffer after output + (when (boundp 'eshell-output-filter-functions) + (push 'eshell-truncate-buffer eshell-output-filter-functions)))) + +(use-package multi-term + :ensure t + :defer t + :init + (progn + (defun multiterm (_) + "Wrapper to be able to call multi-term from shell-pop" + (interactive) + (multi-term))) + :config + (progn + (defun term-send-tab () + "Send tab in term mode." + (interactive) + (term-send-raw-string "\t")) + (add-to-list 'term-bind-key-alist '("<tab>" . term-send-tab)))) + +(use-package shell-pop + :ensure t + :defer t + :bind (("C-:" . shell-pop)) + :init + (progn + (setq shell-pop-window-position 'bottom + shell-pop-window-size 30 + shell-pop-term-shell 'ansi-term + shell-pop-full-span t) + (defmacro make-shell-pop-command (type &optional shell) + (let* ((name (symbol-name type))) + `(defun ,(intern (concat "shell-pop-" name)) (index) + (interactive "P") + (require 'shell-pop) + (shell-pop--set-shell-type + 'shell-pop-shell-type + (backquote (,name + ,(concat "*" name "*") + (lambda nil (funcall ',type ,shell))))) + (shell-pop index)))) + (make-shell-pop-command eshell) + (make-shell-pop-command shell) + (make-shell-pop-command term shell-pop-term-shell) + (make-shell-pop-command multiterm) + (make-shell-pop-command ansi-term shell-pop-term-shell))) + +(provide 'core-term) |