Here is my setup:
(defvar terminal-process) (defun terminal () "Switch to terminal. Launch if nonexistant." (interactive) (if (get-buffer "*terminal*") (switch-to-buffer "*terminal*") (term "/bin/bash")) (setq terminal-process (get-buffer-process "*terminal*"))) (global-set-key "\Ct" 'terminal)
Could you tell us more about the launch time? My is about 0.3 s.
UPD A small fragment from my dired setup
I have this in my dired setup:
(add-hook 'dired-mode-hook (lambda() (define-key dired-mode-map (kbd "`") (lambda()(interactive) (let ((current-dir (dired-current-directory))) (term-send-string (terminal) (format "cd %s\n" current-dir)))))))
where terminal :
(defun terminal () "Switch to terminal. Launch if nonexistant." (interactive) (if (get-buffer "*terminal*") (switch-to-buffer "*terminal*") (term "/bin/bash")) (setq terminal-process (get-buffer-process "*terminal*")))
What this means is, it opens a terminal for the same directory as the rewritten buffer, reusing the existing *terminal* or creating a new one if it is missing.
To summarize the answer to your question:
Yes it is possible. This is done using:
(term-send-string (terminal) (format "cd %s\n" default-directory))
source share