Three ansi-term tips
01 Jan 2015Tip #1
There's no reason not to have /bin/bash
instead of /bin/sh
as the
default choice when you M-x term
.
(setq explicit-shell-file-name "/bin/bash")
Tip #2
After you close the terminal, you get a useless buffer with no process. It's probably left there for you to have a history of what you did. I find it not useful, so here's a way to kill that buffer automatically:
(defun oleh-term-exec-hook ()
(let* ((buff (current-buffer))
(proc (get-buffer-process buff)))
(set-process-sentinel
proc
`(lambda (process event)
(if (string= event "finished\n")
(kill-buffer ,buff))))))
(add-hook 'term-exec-hook 'oleh-term-exec-hook)
Tip #3
By default, C-y calls term's own yank
, which is different
from Emacs's yank
. So, until recently, I was using
S-<insert> to paste stuff into *term*
. Here's a
more ergonomic way:
(eval-after-load "term"
'(define-key term-raw-map (kbd "C-c C-y") 'term-paste))