diff options
-rw-r--r-- | emacs.d/init.el | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/emacs.d/init.el b/emacs.d/init.el index fdddbc1..0052749 100644 --- a/emacs.d/init.el +++ b/emacs.d/init.el @@ -236,6 +236,42 @@ ;; (dolist (var '("GEM_HOME" "MY_RUBY_HOME")) ;; (unless (getenv var) ;; (exec-path-from-shell-copy-env var)))) +(use-package term + :bind (("C-x t" . fc/open-term) + ("C-x m" . fc/switch-to-term-buffer)) + :config + (progn + (defun fc/make-term (new-buffer-name cmd &rest switches) + (setq term-ansi-buffer-name (concat "<" new-buffer-name ">")) + (setq term-ansi-buffer-name (generate-new-buffer-name term-ansi-buffer-name)) + (setq term-ansi-buffer-name (apply 'make-term term-ansi-buffer-name cmd nil switches)) + (set-buffer term-ansi-buffer-name) + (term-mode) + (term-char-mode) + (term-set-escape-char ?\C-x) + (switch-to-buffer term-ansi-buffer-name)) + + (defun fc/open-term (name) + (interactive "sName: ") + (fc/make-term name "bash")) + + (defun fc/list-term-buffers () + "Returns a list of term buffers" + (delq nil + (mapcar (lambda(x) + (set-buffer x) + (when (string= major-mode "term-mode") + (buffer-name))) + (buffer-list)))) + + (defun fc/switch-to-term-buffer () + "Switch to a term buffer." + (interactive) + (let ((collection (fc/list-term-buffers))) + (ivy-read "term buffers:" collection + :action (lambda (x) (switch-to-buffer x)) + :caller 'fc/find-term-buffers))))) + ;; some bindings (global-set-key (kbd "M-j") 'join-line) |