From d277d763794c17f99aca174cd9a415c12ccb07ef Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Fri, 8 Apr 2016 15:36:33 -0700 Subject: [emacs] Add configuration for ansi-term Add configuration for ansi-term and use the package 'shell-pop' to pop a terminal. This is binded to 'C-:'. Most of the configuration is coming from 'spacemacs'. --- emacs.d/core/core-term.el | 93 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 emacs.d/core/core-term.el (limited to 'emacs.d/core') 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 '("" . 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) -- cgit 1.4.1