summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-05-23 22:17:55 -0400
committerKyle Meyer <kyle@kyleam.com>2014-05-23 22:17:55 -0400
commit3144f6487318742c1cbd5eb707cc0b0a374035e3 (patch)
tree8ff547bdbf6918fca81ba4fd1b762260564821d1
parentd1d15a1456720a3ac31169cc1a9ecf2bc99838e7 (diff)
downloademacs.d-3144f6487318742c1cbd5eb707cc0b0a374035e3.tar.gz
Use default-directory in ansi-term buffer name
By default, switch to ansi-term buffer for directory if it already exists.
-rw-r--r--lisp/init-external.el14
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/init-external.el b/lisp/init-external.el
index c9d39ae..be8cdcd 100644
--- a/lisp/init-external.el
+++ b/lisp/init-external.el
@@ -20,9 +20,17 @@ other window when an asynchronous command is run."
(define-prefix-command 'external-map)
(global-set-key (kbd "C-c x") 'external-map)
-(defun km/zsh-ansi-term ()
- (interactive)
- (ansi-term "/bin/zsh"))
+(defun km/zsh-ansi-term (&optional new-buffer)
+ "Open an ansi-term buffer running ZSH.
+The buffer is named according to `default-directory'. If a buffer
+of the same name already exists, switch to it unless NEW-BUFFER
+is non-nil, switch to the buffer."
+ (interactive "P")
+ (let ((name (concat "zsh:" (abbreviate-file-name default-directory))))
+ (-if-let (buffer-name (and (not new-buffer)
+ (get-buffer (concat "*" name "*"))))
+ (switch-to-buffer buffer-name)
+ (ansi-term "/bin/zsh" name))))
(defun km/display-compilation-other-window ()
(interactive)