summary refs log tree commit diff
path: root/emacs.d/core
diff options
context:
space:
mode:
authorFranck Cuny <franckcuny@gmail.com>2016-04-08 15:36:33 -0700
committerFranck Cuny <franckcuny@gmail.com>2016-04-08 15:37:31 -0700
commitd277d763794c17f99aca174cd9a415c12ccb07ef (patch)
tree3fd5e473bba5f96ec1975733f2dad981b98ed045 /emacs.d/core
parent[zsh] clean up zsh config. (diff)
downloademacs.d-d277d763794c17f99aca174cd9a415c12ccb07ef.tar.gz
[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'.
Diffstat (limited to 'emacs.d/core')
-rw-r--r--emacs.d/core/core-term.el93
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)