Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
142 lines (119 sloc) 3.93 KB
(require 'multi-term)
(require 'comint)
(setq shell-command-switch "-lc")
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
;; multi-term
(autoload 'multi-term "multi-term")
(setq multi-term-program "/bin/bash")
(defun dss/cd-multi-term (dir &optional command switch)
(let (tmp-buffer term-buffer)
;; with-temp-buffer gets in the way here
(set-buffer (setq tmp-buffer (get-buffer-create "*multi-term-launcher*")))
(setq default-directory dir)
;;(setq term-buffer (multi-term))
(setq term-buffer (multi-term-get-buffer current-prefix-arg))
(set-buffer term-buffer)
(kill-buffer tmp-buffer)
(if command
(term-send-raw-string command))
(unless (and (not (eq switch nil))
(< switch 0))
(switch-to-buffer term-buffer))
(defun dss/term-toggle-mode ()
"Toggle between term-char-mode and term-line-mode."
(if (term-in-line-mode)
(defun dss/term-char-mode ()
(defun dss/term-dabbrev ()
(let ((beg (point)))
(dabbrev-expand nil)
(kill-region beg (point)))
(term-send-raw-string (substring-no-properties (current-kill 0))))
(defun dss/term-backward-kill-word ()
(if (term-in-line-mode)
(backward-kill-word 1)
(add-hook 'term-mode-hook
'(lambda ()
(define-key term-raw-escape-map "/"
(define-key term-mode-map (kbd "C-c C-j")
(define-key term-mode-map (kbd "M-DEL")
(define-key term-mode-map (kbd "M-g")
(linum-mode -1)))
(defun dss/term-yank ()
(if (term-in-line-mode)
(defun dss/term-reverse-search ()
(if (term-in-line-mode)
;(defun term-forward-search ()
; (interactive)
; (if (term-in-line-mode)
; (isearch-forward)
; (term-send-forward-search-history)))
;;; derived from
(defun dss/term-setup-tramp ()
"Setup ansi-term/tramp remote directory tracking"
(term-send-raw-string "
# Emacs ansi-term/tramp remote directory tracking
if [ $TERM = eterm-color ]; then
function eterm-set-cwd {
echo -e \"\\033AnSiTc\" $(pwd)
# set hostname, user, and cwd
function eterm-reset {
echo -e \"\\033AnSiTu\" ${TRAMP_USERNAME-$(whoami)}
echo -e \"\\033AnSiTc\" $(pwd)
echo -e \"\\033AnSiTh\" ${TRAMP_HOSTNAME-$(hostname)}
for temp in cd pushd popd; do
alias $temp=\"eterm-set-cwd $temp\"
# set hostname, user, and cwd now
(setq term-bind-key-alist
'(("C-c C-c" . term-interrupt-subjob)
("C-x C-x" . term-send-raw)
;("C-p" . term-send-raw);previous-line)
;("C-n" . term-send-raw);next-line)
("C-s" . isearch-forward)
("C-r" . dss/term-reverse-search)
("C-m" . term-send-raw)
("M-f" . term-send-forward-word)
("M-b" . term-send-backward-word)
("M-o" . term-send-backspace)
("M-p" . term-send-up)
("M-n" . term-send-down)
("M-N" . term-send-backward-kill-word)
("M-r" . term-send-reverse-search-history)
("M-," . term-send-input)
("M-." . comint-dynamic-complete)
("Od" . term-send-backward-word)
("Oc" . term-send-forward-word)
("M-d" . term-send-forward-kill-word)
("M-g" . dss/term-toggle-mode)
("C-y" . dss/term-yank)))
;; also see
(provide 'dss-term)
Jump to Line
Something went wrong with that request. Please try again.