summaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMartin Polden <martin.polden@gmail.com>2014-10-24 11:46:45 +0100
committerMartin Polden <martin.polden@gmail.com>2014-10-25 13:20:41 +0200
commitffbe116c6ea83f9f38d594075a78d50987d4f391 (patch)
treeacc3ec152d4cbff414707b65dfcbf5d0a3dc5c81 /lisp
parentd63b21ca0843084185db71493b3d96dd35d13d17 (diff)
Add function for starting ansi-term
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-shell.el20
1 files changed, 19 insertions, 1 deletions
diff --git a/lisp/init-shell.el b/lisp/init-shell.el
index 12e641a..a18b870 100644
--- a/lisp/init-shell.el
+++ b/lisp/init-shell.el
@@ -1,4 +1,5 @@
(require 'eshell)
+(require 'term)
(defun eshell-other-window (&optional noselect)
"Create an interactive Eshell buffer in another window."
@@ -16,6 +17,23 @@
(when noselect
(select-window current-window))))
-(global-set-key (kbd "C-c k") 'eshell-other-window)
+(defun ansi-term-other-window (&optional noselect)
+ "Start a terminal-emulator in another window. Adapted from
+`ansi-term'."
+ (interactive)
+ (let ((current-window (selected-window))
+ (buf-name (generate-new-buffer-name "*ansi-term*"))
+ (shell (or (getenv "ESHELL")
+ (getenv "SHELL")
+ "/bin/sh")))
+ (term-ansi-make-term buf-name shell)
+ (with-current-buffer buf-name
+ (term-mode)
+ (term-char-mode))
+ (switch-to-buffer-other-window buf-name)
+ (when noselect
+ (select-window current-window))))
+
+(global-set-key (kbd "C-c k") 'ansi-term-other-window)
(provide 'init-shell)