diff options
author | William Carroll <wpcarro@gmail.com> | 2017-06-06T14·35-0400 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2017-06-06T14·35-0400 |
commit | 981f86bf7d8368b2925ac62bb97742ad9d6b9be0 (patch) | |
tree | 04e32ee2198d2238198268158a3f1eead57cda66 /emacs | |
parent | d688393344d254339144623863a8e430c56decf3 (diff) |
Removes unnecessary kbds; enhances config
Diffstat (limited to 'emacs')
-rw-r--r-- | emacs/wc-helper-functions.lisp | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/emacs/wc-helper-functions.lisp b/emacs/wc-helper-functions.lisp index 272b80809dd8..7b0704d679ea 100644 --- a/emacs/wc-helper-functions.lisp +++ b/emacs/wc-helper-functions.lisp @@ -1,12 +1,32 @@ (defun wc/projectile-shell-pop () "Opens `ansi-term' at the project root according to Projectile." (interactive) - (let ((default-directory (projectile-project-root))) - (if (get-buffer "*ansi-term*") - (switch-to-buffer "*ansi-term*") - (ansi-term "/bin/zsh")) - (term-send-string (terminal) (format "cd '%s'\n" default-directory)) - (get-buffer-process "*ansi-term*"))) + (let* ((project-name (projectile-project-root)) + (default-directory project-name) + (buffer-name (format "ansi-term <%s>" project-name))) + (if (get-buffer buffer-name) + (switch-to-buffer buffer-name) + (ansi-term "/bin/zsh" buffer-name)))) + + +(defun wc/ansi-term-project-p (input) + (string-match-p "*ansi-term <[^>]+>*" input)) + + +(defun wc/list-project-terminals () + "Returns a list of ansi-term buffers with associated projects." + (interactive) + (let ((buffer-names (mapcar 'buffer-name (buffer-list)))) + (remove-if-not #'wc/ansi-term-project-p buffer-names))) + + +(defun wc/open-terminals () + "Lists active terminal buffers." + (interactive) + (helm :sources (helm-build-in-buffer-source "test1" + :data (wc/list-project-terminals) + :action 'switch-to-buffer) + :buffer "*helm projectile terminals*")) (defun wc/shell-history () @@ -71,6 +91,14 @@ (lookup-key (current-global-map) binding))) +(defun wc/focus-term-at-bottom () + "Moves term to the bottom of the page on insert mode." + (interactive) + (end-of-buffer) + (evil-insert-state) + (term-send-raw-string "\b")) + + (defun wc/bootstrap-ansi-term () "Custom `ansi-term' configuration." (interactive) @@ -81,6 +109,9 @@ (local-set-key (kbd "C-k") 'evil-window-up) (local-set-key (kbd "C-j") 'evil-window-down) (wc/expose-global-binding-in-term (kbd "M-x")) + (evil-define-key 'normal term-raw-map + (kbd "C-c") 'term-interrupt-subjob + (kbd "i") 'wc/focus-term-at-bottom) (define-key term-raw-map (kbd "C-r") 'wc/helm-shell-history) (define-key term-raw-map (kbd "M-:") 'eval-expression) (define-key term-raw-map (kbd "M-j") 'wc/helm-autojump) |